#include #include constexpr int INF = 1 << 30; void solve() { int n; std::cin >> n; std::vector dp(10, -INF); dp[0] = 0; while (n--) { int x; std::cin >> x; x %= 10; auto ndp = dp; for (int y = 0; y < 10; ++y) { ndp[(x + y) % 10] = std::max(ndp[(x + y) % 10], dp[y] + 1); } std::swap(dp, ndp); } std::cout << dp[0] << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }