# coding: utf-8 # Your code here! def ketawa(x): while x > 9: y = 0 while x > 0: y += (x % 10) x = x // 10 x = y return x N = int(input()) X = 1 P = input().split() for i in P: X = ketawa(X * ketawa(int(i))) print(X)