#include #include using namespace std; int main(){ int n; cin >> n; int x[10] = {}; for(int i = 0; i < n; i++){ int a; cin >> a; x[a%10]++; } int ans = x[0]; for(int i = 1; i < 10; i++){ if(x[i]%10) ans += x[i]/10*10, x[i] %= 10; else ans += x[i]-10, x[i] = 10; } int dp[1001]; memset(dp, -1, sizeof(dp)); dp[0] = 0; for(int i = 1; i < 10; i++){ for(int j = 0; j < x[i]; j++){ for(int k = 1000-i; k >= 0; k--){ if(dp[k] == -1) continue; dp[k+i] = max(dp[k+i], dp[k]+1); } } } int ma = 0; for(int i = 0; i < 1000; i += 10) ma = max(ma, dp[i]); cout << ans+ma << endl; return 0; }