N = input() P = sum(map(int, input().split())) if P: print((P - 1) % 9 + 1) else: print(0)