#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N); for (auto&& e : A) { cin >> e; e %= 10; } vector dp(10, -1); dp[0] = 0; for (int i = 0; i < N; i++) { vector ndp(10, -1); for (int j = 0; j < 10; j++) { if (dp[j] == -1) continue; ndp[j] = max(ndp[j], dp[j]); ndp[(j + A[i]) % 10] = max(ndp[(j + A[i]) % 10], dp[j] + 1); } dp = ndp; } cout << dp.front() << '\n'; return 0; }