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