#include <iostream>
using namespace std;
int main() {
int n, temp, ans = 0, sum = 0;
cin >> n;
while (n--) {
cin >> temp;
while (temp > 0) {
sum += temp % 10;
temp /= 10;
}
}
if (sum < 10) {
cout << sum;
return 0;
}
ans = sum;
while (ans >=10) {
sum = 0;
while (ans > 0) {
sum += ans % 10;
ans /= 10;
}
ans = sum;
}
cout << ans << endl;
}