#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define MOD 1000000007 ll dp[200010][10]; int main(){ ll n; cin>>n; clr(dp,-1); dp[0][0] = 0; rep(i,0,n){ ll a; cin>>a; rep(j,0,10){ if(dp[i][j]==-1)continue; dp[i+1][j] = max(dp[i+1][j],dp[i][j]); dp[i+1][(j+a)%10] = max(dp[i+1][(j+a)%10],dp[i][j]+1); } } cout << dp[n][0] << endl; return 0; }