n = int(input()) a = list(map(int, input().split())) INF = 10 ** 10 for i in range(n): a[i] = a[i] % 10 dp = [[-INF] * 10 for i in range(n + 1)] dp[0][0] = 0 for i in range(n): for j in range(10): dp[i + 1][j] = max(dp[i][(j - a[i]) % 10] + 1, dp[i + 1][j], dp[i][j]) print(dp[-1][0])