#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int mx = 1000;
vector<int> avb;
int n, k;
vector<int> brc;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  scanf("%d%d", &n, &k);
  avb.resize(mx + 1, 0);
  int tt;
  for (int z = 0; z < (k); ++z) {
    scanf("%d", &tt);
    avb[tt] = 1;
  }
  int hmn = inf;
  int hmx = -inf;
  int fmn = inf;
  int fmx = -inf;
  for (int i = 0; i < ((int((avb).size()))); ++i) {
    if (avb[i]) {
      if (i >= n) fmn = min(fmn, i);
      if (i <= n) fmx = max(fmx, i);
      hmn = min(hmn, i);
      hmx = max(hmx, i);
    }
  }
  if (hmn > n || hmx < n) {
    cout << -1 << endl;
    return 0;
  }
  int ubd = max(1, fmn - fmx);
  vector<int> nuavb(mx + 1, 0);
  for (int i = 0; i < ((int((avb).size()))); ++i) {
    if (avb[i]) nuavb[i - hmn] = 1;
  }
  n -= hmn;
  avb = nuavb;
  const int lmx = ubd * mx;
  brc.resize(lmx + 1, inf);
  brc[0] = 0;
  for (int i = 0; i < ((int((avb).size()))); ++i) {
    if (avb[i]) {
      for (int j = 0; j + i <= lmx; ++j) {
        brc[j + i] = min(brc[j + i], brc[j] + 1);
      }
    }
  }
  for (int j = 1; j <= ubd; ++j) {
    if (brc[j * n] <= j) {
      cout << j << endl;
      return 0;
    }
  }
  assert(0);
  return 0;
}
