#pragma GCC optimize("O3") #include #define ll long long #define rep(i,n) for(ll i=0;i<(n);i++) #define pll pair #define pii pair #define pq priority_queue #define pb push_back #define eb emplace_back #define fi first #define se second #define endl '\n' #define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define lb(c,x) distance(c.begin(),lower_bound(all(c),x)) #define ub(c,x) distance(c.begin(),upper_bound(all(c),x)) using namespace std; int main(){ ll n; cin >> n; vector a(n); rep(i,n){ cin >> a[i]; a[i]%=10; } vector> dp(n+1,vector(10,-1)); dp[0][0]=0; rep(i,n){ rep(j,10){ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); if(dp[i][(j-a[i]+10)%10]!=-1){ dp[i+1][j]=max(dp[i][(j+10-a[i])%10]+1,dp[i+1][j]); } } } cout << dp[n][0] << endl; return 0; }