""" Game of Nines When does it become impossible to make a 9? All addition is done mod 10, so if every value divisible by 2 or every value is divisible by 5, there is nothing we can do. If we have 1, 3, or 7, then we can delete every digit but the odd one. If we have an even digit besides 4 and a 5, we can make one of the above digits so the answer is 1. Remaining cases are all even (nothing), all 0/5 (nothing), or only 4s and 5s? """ def solve(freq): n = sum(freq) ans = n if any(freq[d] > 0 for d in [1, 3, 7]): ans = 1 elif freq[5] > 0 and any(freq[d] > 0 for d in [2, 6, 8]): ans = 1 elif freq[5] > 0 and freq[4] > 0: # Either combine 2 4s into an 8 and reduce to above, or only 1 4 so delete everything else ans = 1 else: ans = n return ans n = int(input()) freq = [0 for _ in range(9)] for _ in range(n): freq[int(input())] += 1 print(solve(freq))