N = int(input()) A = list(map(int, input().split())) # dp[mod] = 最大の枚数 dp = [-1] * 10 dp[0] = 0 for a in A: dp_tmp = [-1] * 10 for i in range(10): if dp[i] == -1: continue dp_tmp[i] = max(dp[i], dp_tmp[i]) n = (i + a) % 10 dp_tmp[n] = max(dp[i] + 1, dp_tmp[n]) dp = dp_tmp print(dp[0])