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