#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long #define double long double typedef vector VI; typedef pair pii; typedef vector VP; typedef vector VS; typedef priority_queue PQ; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i, greater > q2; int dp[200010][10]; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; VI A(N); REP(i, N)cin >> A[i]; REP(i, 200010)REP(j, 10)dp[i][j] = -1; dp[0][0] = 0; REP(i, N) { int now = A[i]; REP(j, 10) { if (dp[i][j] != -1)chmax(dp[i + 1][(j + now) % 10], dp[i][j] + 1); chmax(dp[i + 1][j], dp[i][j]); } } cout << dp[N][0] << endl; return 0; }