#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> vec;
int sum = 0;
for (int i = 0; i < n; i++) {
int t;
cin >> t;
vec.push_back(t);
}
for (int i = 0; i < n; i++) {
while (vec[i] / 10 != 0) {
int sum = 0;
while (vec[i] != 0) {
sum += (vec[i] % 10);
vec[i] = vec[i] / 10;
}
vec[i] = sum;
}
}
int f = 0;
for (auto i : vec) {
f += i;
}
while (f / 10 != 0) {
int sum = 0;
while (f != 0) {
sum += (f % 10);
f = f / 10;
}
f = sum;
}
cout << f << endl;
return 0;
}
Copy