n = int(input()) s = [int(i) for i in input().split()] c = 1 cs = 0 for a in s: c *= a # print(c) print(c%9)