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