// #include "pch.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; typedef std::pair Pii; typedef std::pair Pll; typedef std::pair Pdd; #define rip(i, n, s) for (int i = (s);i < (int)( n ); i++) #define all(a) a.begin(), a.end() #define MM << " " << template using MaxHeap = std::priority_queue; template using MinHeap = std::priority_queue, std::greater>; 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; } # ifndef ONLINE_JUDGE template void vdeb(std::vector &bb) { for (int i = 0;i < bb.size();i++) { if (i == bb.size() - 1) std::cout << bb[i]; else std::cout << bb[i] << ' '; } std::cout << '\n'; } template void vdeb(std::vector> &bb) { for (int i = 0;i < bb.size();i++) { std::cout << i << ' '; vdeb(bb[i]); } std::cout << '\n'; } # endif using namespace std; int main(){ int n; cin >> n; vector da(n); rip(i,n,0) cin >> da[i]; vector> dp(n+1, vector(10, -n*2)); dp[0][0] = 0; rip(i,n,0) { int now = da[i]%10; rip(j,10,0){ chmax(dp[i+1][j], dp[i][j]); chmax(dp[i+1][j], dp[i][(j+now)%10]+1); } } // vdeb(dp); cout << dp[n][0] << endl; }