#include <bits/stdc++.h>
using namespace std;
const int M = 300000, N = 1000000;
int n, k, r, i, j, a[1005], o, ans = 100000000, sol[N][2];
bool x[10005] = {}, u = 0;
;
int main() {
  cin >> n >> k;
  j = 0;
  for (i = 0; i < k; i++) {
    scanf("%d", &o);
    if (x[o] == 0) {
      x[o] = 1;
      a[j] = o;
      j++;
    }
    if (o == n) u = 1;
  }
  if (u) {
    cout << 1 << endl;
    return 0;
  }
  for (i = 0; i < j; i++) a[i] -= n;
  sort(a, a + j);
  if (a[j - 1] < 0 || a[0] > 0) {
    cout << -1 << endl;
    return 0;
  }
  sol[i][0] = 0;
  sol[i][1] = 0;
  for (int i = 1; i < N; i++) {
    o = 100000000;
    for (r = 0; r < j; r++) {
      while (i + a[r] < 0) r++;
      if (a[r] > 0) break;
      o = min(o, sol[i + a[r]][0] + 1);
    }
    sol[i][0] = o;
    o = 100000000;
    for (; r < j; r++) {
      if (i - a[r] < 0) break;
      o = min(o, sol[i - a[r]][1] + 1);
    }
    sol[i][1] = o;
    ans = min(ans, sol[i][0] + sol[i][1]);
  }
  cout << ans << endl;
  return 0;
}
