#include #include using namespace std; using LL = long long; using P = pair; using Graph = vector>; const int INF = 1 << 29; const long long LINF = 1LL << 60; #define all(x) (x).begin(), (x).end() #define rep(i,n) for(int i = 0; i < (n); ++i) templatevoid chmin(T&a, T b){if(a > b) a = b;} templatevoid chmax(T&a, T b){if(a < b) a = b;} int main(){ int N; cin >> N; vector A(N); for(int i = 0; i < N; ++i) cin >> A[i]; vector> dp(N+1, vector(10,0)); for(int i = 0; i < N; ++i){ if(dp[i][A[i]%10]==0) dp[i+1][A[i]%10] = 1; for(int j = 0; j < 10; ++j){ if(dp[i][j]!=0){ chmax(dp[i+1][(j+A[i])%10], dp[i][j]+1); chmax(dp[i+1][j], dp[i][j]); } } } cout << dp[N][0] << endl; }