#include using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; } template bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; } template T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; } template T lcm(T a, T b){ return a / gcd(a, b) * b; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N); rep(i, 0, N){ cin >> A[i]; A[i] %= 10; } vector dp(N+1, vector(10, -1)); dp[0][0] = 0; rep(i, 0, N){ rep(j, 0, 10){ if(dp[i][j] == -1) continue; 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; return 0; }