# coding: utf-8 # Your code here! N=int(input()) A=list(map(int,input().split())) dp=[-1]*10 dp[0]=0 for a in A: temp=dp[:] for i in range(10): if dp[i]!=-1: temp[(a+i)%10]=max(dp[i]+1,temp[(a+i)%10]) dp=temp[:] print(dp[0])