#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("YES");}else{puts("NO");} #define MAX_N 200005 int main() { int n; cin >> n; int a[n] = {}; rep(i,n){ cin >> a[i]; a[i] %= 10; } int dp[10] = {}; srep(i,1,10) dp[i] = -1001001001; rep(j,n){ int x = a[j]; int dp2[10]; rep(i,10) dp2[i] = dp[i]; rep(i,10){ dp2[(i+x)%10] = max(dp2[(i+x)%10], dp[i] + 1); } rep(i,10) dp[i] = dp2[i]; } cout << dp[0] << endl; return 0; }