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