N=int(input()) P=list(map(int,input().split())) A=1 for p in P: A*=p while len(str(A))>1: Q=0 for q in str(A): Q+=int(q) A=Q print(A)