#include <iostream>
using namespace std;
int main()
{
long int numOfIns, sum=0, tempsum=0;
cin >> numOfIns;
for (int i=0; i<numOfIns; i++){
long int v;
cin >> v;
sum += v;
}
while(sum/10 != 0){
tempsum=0;
while(sum/10 != 0){
tempsum+=(sum%10);
sum/=10;
}
tempsum+=(sum%10);
sum = tempsum;
}
if(sum >= 0) cout << sum;
else if(sum < 0) cout << -1*sum;
return 0;
}