#include <bits/stdc++.h>
using namespace std;
const int N = 1003;
int n, k;
bitset<N * 3> A, dp, dpt;
int main() {
  scanf("%d%d", &n, &k);
  for (int a; k; k--) scanf("%d", &a), A[a] = 1;
  dp[1500] = 1;
  for (int __ = 1; __ <= 1009; __++) {
    dpt = 0;
    for (int i = 0; i < 3000; i++)
      if (dp[i] == 1) dpt |= A << (i - n);
    dp = dpt;
    if (dp[1500] == 1) return !printf("%d\n", __);
  }
  return !printf("-1\n");
}
