#include <iostream>
using namespace std;
int main() {
int n;
cin>>n;
long long bigsum=0;
for(int i=0; i<n; i++){
long long input;
cin>>input;
bigsum+=input;
}
while(bigsum>9){
long long summation=0;
long long finalsum=bigsum;
while(finalsum!=0){
summation+=finalsum%10;
finalsum/=10;
}
bigsum=summation;
}
cout<<bigsum;
return 0;
}