#include using namespace std; #define lli long long int #define uli unsigned long long int #define INF 99999999999 #define rep(i,m,n) for(lli i = m;i < n;i++) #define rrep(i,m,n) for(lli i=m;i>n;i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(),N.end()),N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(),n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(20) << S << endl #define Vecpr(K,L1,L2,N) vector> K(N) #define Vec(K,L,N,S) vector K(N,S) #define DV(K,L,N,M,R) vector> K(N, vector(M,R)) #define mod 1000000007 #define MAX 5100000 #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) int main(){ lli N,sum=1; cin >> N; Vec(P,lli,N,0); rep(i,0,N)cin >> P[i]; Sort(P); if(P[0]==0)Out(0); else{ rep(i,0,N)sum=sum%9*P[i]%9; if(sum==0)Out(9); else Out(sum); } }