#include <iostream>
using namespace std;
int main()
{
int numOfIns, sum=0, tempsum=0;
cin >> numOfIns;
for (int i=0; i<numOfIns; i++){
int v;
cin >> v;
sum += v;
}
while(sum/10 != 0){
tempsum=0;
while(sum/10 != 0){
tempsum+=sum%10;
sum/=10;
cout << " thisb debug -> " << sum << "\t tempsum ->" << tempsum<< endl;
}
tempsum+=sum%10;
sum = tempsum;
}
cout << sum;
return 0;
}