N = int(input()) A = list(map(int,input().split())) inf = -(1 << 30) dp = [[inf] * 10 for _ in range(N)] dp[0][0] = 0 dp[0][A[0]%10] = 1 for i in range(N-1): for j in range(10): dp[i+1][(j+A[i+1])%10] = max(dp[i+1][(j+A[i+1])%10],dp[i][j] + 1) for j in range(10): dp[i+1][j] = max(dp[i+1][j],dp[i][j]) print(dp[-1][0])