N = int(input()) DP = [0] + [-N] * 9 for a in map(int, input().split()): a %= 10 DP = [max(DP[i], DP[i - a] + 1) for i in range(10)] print(DP[0])