N = int(input()) A = list(map(int, input().split())) rem = [-1] * 10 rem[0] = 0 for i in range(N): a = A[i] % 10 tmp = rem.copy() for j in range(10): if rem[(j - a) % 10] != -1: tmp[j] = max(rem[j], rem[(j - a) % 10] + 1) rem = tmp.copy() print(rem[0])