#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10;
const int OFFSET = 1e3;
int n, k;
bool have[MAXN];
int d[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  int x;
  vector<int> vals;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> x;
    if (have[x] == false) vals.push_back(x);
    have[x] = true;
  }
  sort(vals.begin(), vals.end());
  memset(d, -1, sizeof d);
  queue<int> q;
  for (int i = 0; i <= 1000; i++) {
    if (have[i]) {
      d[i - n + OFFSET] = 1;
      q.push(i - n);
    }
  }
  for (auto &elem : vals) elem -= n;
  while (q.size() > 0) {
    int f = q.front();
    q.pop();
    for (auto &elem : vals) {
      if (elem + f + OFFSET >= 0 && elem + f + OFFSET < MAXN &&
          d[elem + f + OFFSET] == -1) {
        d[elem + f + OFFSET] = d[f + OFFSET] + 1;
        q.push(elem + f);
      }
    }
  }
  cout << d[OFFSET] << '\n';
  return 0;
}
