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): if x==0: return 0 res=x%9 if res==0: res=9 return res ans=0 for i in range(N): P[i]=ch(P[i]) ans+=P[i] while ans>=10: ans=ch(ans) print(ans) main()