def calc(x): ret = 0 while x > 0: ret += x % 10 x //= 10 return ret def main(): N = int(input()) P = list(map(int, input().split())) A = 1 for p in P: A *= calc(p) A = calc(A) print(calc(A)) if __name__ == "__main__": main()