import math def is_prime(n): for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def primes(m): for i in range(2, m): if is_prime(i): yield i m = int(input()) n = input() values = list(map(int, input().split())) dp = [0] * 10001 ans = 0 for i, value in enumerate(values): dp[value] += 1 for i, value in enumerate(values): for j in range(m + 1): if dp[j] > 0 and j + value <= m: dp[j + value] = max(dp[j] + 1, dp[j + value]) for prime in primes(m): ans += dp[m - prime] ans += max(dp) print(ans)