n = int(input()) a = list(map(int, input().split())) def keta(x): ret = 0 while(x): ret += x % 10 x = x // 10 return ret k = 1 for i in range(n): k *= keta(a[i]) k = keta(k) print(keta(k))