#include <bits/stdc++.h>
using namespace std;
bool testando = 0;
int main() {
  set<int> s;
  int nwt, k, aux;
  cin >> nwt >> k;
  for (int i = 0; i < (k); i++) scanf("%d", &aux), s.insert(aux);
  vector<int> dif;
  bool tempos = 0, temneg = 0;
  for (__typeof((s).begin()) it = (s).begin(); it != (s).end(); it++) {
    dif.push_back(*it - nwt);
    if (*it - nwt < 0)
      temneg = 1;
    else if (*it - nwt > 0)
      tempos = 1;
    else {
      cout << 1 << endl;
      return 0;
    }
  }
  if (!temneg or !tempos) {
    cout << -1 << endl;
    return 0;
  }
  sort(dif.begin(), dif.end());
  vector<int> vp, vn;
  for (int i = 0; i < (dif.size()); i++) {
    if (dif[i] < 0) {
      vn.push_back(dif[i]);
    } else if (dif[i] > 0) {
      vp.push_back(dif[i]);
    }
  }
  vector<bool> vb(vp.back() + nwt + 1, 0);
  vb[nwt] = 1;
  vector<bool> vb2(vp.back() + nwt + 1, 0);
  for (int ii = 0; ii < (1001); ii++) {
    for (int i = 0; i < (vb.size()); i++) {
      if (vb[i]) {
        vb[i] = 0;
        if (i >= nwt) {
          for (int j = 0; j < (vn.size()); j++) {
            if (i + vn[j] >= 0) {
              vb2[i + vn[j]] = 1;
            }
          }
        }
        if (i <= nwt) {
          for (int j = 0; j < (vp.size()); j++) {
            if (i + vp[j] < vb.size()) {
              vb2[i + vp[j]] = 1;
            }
          }
        }
      }
      if (vb2[nwt]) {
        cout << ii + 1 << endl;
        return 0;
      }
    }
    vb = vb2;
    vb2 = vector<bool>(vb.size(), 0);
  }
  cout << "ERRO" << endl;
  return 0;
}
