#include using namespace std; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using P = pair; const long double PI = acos(-1.0L); ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; } ll LCM(ll a, ll b) { return a/GCD(a, b)*b; } int main() { int n; cin >> n; vector avec(n, 0); for(int i = 0; i < n; ++i) cin >> avec[i]; vector< vector > dp(n+1, vector(15, 0)); for(int i = 0; i < n; ++i) { chmax(dp[i+1][avec[i]%10], 1); for(int j = 0; j < 10; ++j) { if(dp[i][j] > 0) chmax(dp[i+1][(j+avec[i])%10], dp[i][j]+1); chmax(dp[i+1][j], dp[i][j]); } } cout << dp[n][0] << endl; }