n=int(input()) p=list(map(int,input().split())) p=[i%9for i in p] a=1 for i in p:a*=i print(a%9)