n=int(input()) t=map(int,input().split()) x=1 for i in t: x*=i while x>=10: x=sum(int(i) for i in str(x))