#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector a(n); REP (i, n) { cin >> a[i]; a[i] %= 10; } vector dp(10, -1); dp[0] = 0; REP (i, n) { vector dq = dp; REP (j, 10) { if (dp[j] != -1) { int k = (j + a[i]) % 10; dq[k] = max(dp[k], dp[j] + 1); } } dp = dq; } cout << dp[0] << endl; return 0; }