#include using namespace std; #define ll long long typedef pair P; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } #define M 1000000007 #define all(a) (a).begin(),(a).end() #define rep(i,n) reps(i,0,n) #define reps(i,m,n) for(int i=(m);i<(n);i++) int main(){ map m; rep(i,10){ reps(j,i,10){ ll c=i*j,d=0LL; while(c>=10){ ll d=0LL,b=c; while(b){ d+=b%10;b/=10; } c=d; } m[P(i,j)]=c;m[P(j,i)]=c; } } ll n,a,r=1LL;cin>>n; rep(i,n){ cin>>a; while(a>=10){ ll b=a,d=0LL; while(b){ d+=b%10;b/=10; } a=d; } r=m[P(r,a)]; } cout<