n = int(input()) li = list(map(int,input().split())) k = 1 for p in li: k*=p while k>=10: t=0 while k: t+=k%10 k//=10 k=t print(k)