#include using namespace std; /* typedef */ typedef long long ll; typedef pair pii; /* constant */ const int INF = 1 << 30; const ll LINF = 1LL << 61; const int NIL = -1; const int MAX = 10000; const int MOD = 1000000007; const double pi = 3.141592653589; /* global variables */ /* function */ /* main */ int main(){ int n; cin >> n; vector a(n); for (int &ai : a) cin >> ai; vector dp(10, NIL); // mod 10 dp[0] = 0; for (int i = 0; i < n; i++) { vector tmp = dp; for (int k = 0; k < 10; k++) { if (dp[k] == NIL) continue; int nk = (a[i] + k) % 10; tmp[nk] = max(tmp[nk], dp[k] + 1); } swap(tmp, dp); } cout << dp[0] << '\n'; }