#include <iostream>
using namespace std;
int main()
{
long long n, a[100000], sum = 0;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
long long ans = 0;
for (int i = 0; i < n; i++) {
int x = 0;
while (a[i] >= 0) {
x += a[i] % 10;
a[i] /= 10;
}
a[i] = x;
}
for (int i = 0; i < n; i++) {
sum += a[i];
}
while (sum /10 > 0)
{
ans = 0;
while (ans >= 0) {
ans += sum % 10;
ans /= 10;
}
sum = ans;
}
cout << sum;
}