#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int SZ = 1e6 + 7;
const int INF = 1e9 + 7;
int a[N];
int x, n;
bitset<SZ> bs, nbs;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> x >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int m = unique(a + 1, a + n + 1) - a - 1;
  if (a[1] > x || a[m] < x) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    nbs.set(a[i]);
    if (x == a[i]) {
      cout << 1;
      return 0;
    }
  }
  for (int r = 2; r <= 1000; r++) {
    swap(bs, nbs);
    nbs = 0;
    for (int i = 1; i <= m; i++) {
      nbs |= (bs << a[i]);
    }
    if (nbs[r * x]) {
      cout << r << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
