n=int(input()) P=list(map(int,input().split())) cnt=1 for i in range(n): cnt*=P[i] temp=cnt ans1=0 while temp>=10: ans2=0 while temp>0: ans2+=temp%10 temp//=10 temp=ans2 print(temp)