import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N=I() P=LI() def ch(x): temp=0 while x!=0: temp+=x%10 x=x//10 return temp ans=0 for i in range(N): P[i]=ch(P[i]) ans+=P[i] while ans>=10: ans=ch(ans) print(ans) main()