#include <iostream>
using namespace std;
#define ll long long int
long long int sum_of_digits(ll number) {
ll sum = 0;
while (number != 0) {
sum += number % 10;
number = number / 10;
}
return sum;
}
int main() {
ll sum = 0, number;
ll n;
cin >> n;
while (n--) {
cin >> number;
sum += sum_of_digits(number);
}
number = sum;
while (number >= 10) {
number = sum_of_digits(number);
}
cout << number << endl;
}