# 部分和dpの変形かな # dp[i番目まで見て][j mod 10]の最高枚数 # aはmod 10する N = int(input()) A = list(map(int, input().split())) INF = 10**20 dp = [[-INF]*10 for i in range(N+1)] dp[0][0] = 0 for i in range(1, N+1): num = A[i-1]%10 # 使わない for j in range(10): dp[i][j] = dp[i-1][j] # 使う for j in range(10): dp[i][(j+num)%10] = max(dp[i][(j+num)%10], dp[i-1][j]+1) #print(dp[i]) ans = dp[N][0] print(ans)