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