#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans[25];
void add(ll x){
int digit = 0;
int carry = 0;
while(x){
ans[digit] += x%10;
x/=10;
if(ans[digit] > 9)
carry = 1, ans[digit] -= 10;
digit++;
}
}
void solve(){
int n;
cin>>n;
ll a[n];
for(int i = 0 ; i<n ; i++){
cin>>a[i];
add(a[i]);
}
int sum = 0;
for(int i = 0 ; i<20 ; i++)
sum+=ans[i];
while(sum>9){
int temp = sum;
int sum2 = 0;
while(temp){
sum2 += temp%10;
temp/=10;
}
sum = sum2;
}
cout<<sum;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
#endif
int tt=1;//cin>>tt;
while(tt--)
solve();
}
Copy