#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int 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){ if(dp[i][j] == -1) continue; chmax(dp[i+1][j], dp[i][j]); chmax(dp[i+1][(j+a[i]) % 10], dp[i][j] + 1); } cout << dp[n][0] << endl; }