N = int(input()) A = list(map(int,input().split())) # dp[s] = 合計値を10でわったあまりがsのときに選んだカードの最大枚数 INF = 1 << 60 dp = [-INF] * 10 dp[0] = 0 for i in range(N): new_dp = dp.copy() for s in range(10): if dp[s] == -INF: continue new_dp[(s + A[i]) % 10] = max(new_dp[(s + A[i]) % 10], dp[s] + 1) dp = new_dp print(dp[0])