n = int(input()) *a, = map(int,input().split()) dp = [0]+[-1<<30]*9 for ai in a: ndp = dp[:] for i in range(10): v = (i+ai)%10 ndp[v] = max(ndp[v],dp[i]+1) dp = ndp print(dp[0])