n=int(input()) v=1 a=list(map(int,input().split())) for i in range(n): v*=a[i] while True: v_s=str(v) tmp=0 for i in range(len(v_s)): tmp+=int(v_s[i]) if tmp<10: break else: v=tmp print(tmp)