# coding: utf-8 # Your code here! N=int(input()) P=list(map(int,input().split())) temp=1 judge=False for p in P: if p==0: print(0) exit() temp=(temp*p)%9 if temp==0: judge=True if judge: print(9) else: print(temp)