#include const long long LINF=1e18; using namespace std; //-------------------------↓↓↓↓↓↓------------------------ int main(void){ cin.tie(0); ios::sync_with_stdio(false); long long n, a[2 * 100000 + 10], sum = 0, need, dp[2 * 100000 + 10][15]; cin >> n; assert(n <= 2 * 100000); assert(n >= 1); for(int i = 0; i < n; i++){ cin >> a[i]; assert(a[i] <= 1000000000); assert(a[i] >= 1); a[i] %= 10; sum += a[i]; } if(sum % 10 == 0)cout << n << "\n"; else{ //assert(sum % 10 == 0); need = sum % 10; for(int i = 0; i < n + 5; i++){ for(int j = 0; j < 13; j++){ dp[i][j] = LINF; } } dp[0][0] = 0; if(a[0] != 0){ dp[0][a[0]] = 1; } for(int i = 1; i < n; i++){ for(int j = 0; j < 10; j++){ dp[i][(j + a[i]) % 10] = min(dp[i - 1][(j + a[i]) % 10], dp[i - 1][j] + 1); } } cout << n - dp[n - 1][need] << "\n"; } return 0; }