#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
long long total = 0;
for (int i = 0; i < n; i++) {
long long t;
cin >> t;
total += t;
}
while (total / 10 != 0) {
long long sum = 0;
while (total != 0) {
sum += (total % 10);
total = total / 10;
}
total = sum;
}
cout << total << endl;
return 0;
}