n=int(input()) p=list(map(int,input().split())) a=1 for i in p:a*=i while a>9: b=0 while a>0: b+=a%10 a//=10 a=b print(a)