#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int nn = 1000002;
bitset<3005> dp, dp2;
bool vs[1001];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a;
  for (int i = 0; i < k; ++i) {
    int x;
    scanf("%d", &x);
    if (!vs[x]) a.push_back(x - n), vs[x] = 1;
  }
  int ret = -1;
  dp.set(1500);
  for (int k = 1; k <= 1000; ++k) {
    dp2.reset();
    for (int x : a) {
      if (x >= 0)
        dp2 |= dp << x;
      else
        dp2 |= dp >> (-x);
    }
    dp = dp2;
    if (dp.test(1500)) {
      ret = k;
      break;
    }
  }
  printf("%d\n", ret);
  return 0;
}
