#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
set<pair<int, int> > s;
int coke[N];
vector<int> v[2], ori;
int res, ok[N];
int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    coke[x] = 1;
  }
  bool flag = false;
  int maior;
  for (int i = 0; i <= 1000; i++) {
    if (coke[i]) {
      ori.push_back(i);
      v[0].push_back(i);
      ok[i] = 1;
      if (i >= n) flag = true;
      maior = i;
    }
  }
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  int prv = 0, cur = 1;
  for (int res = 1; res <= 1000; res++) {
    if (ok[n * res] == res) {
      cout << res << endl;
      return 0;
    }
    v[cur].clear();
    for (int j = 0; j < v[prv].size(); j++) {
      for (auto k : ori) {
        int novo = v[prv][j] + k;
        if (novo + maior < n * (res + 1)) continue;
        if (novo > n * (res + 1)) continue;
        if (ok[novo] == res + 1) continue;
        ok[novo] = res + 1;
        v[cur].push_back(novo);
      }
    }
    swap(prv, cur);
  }
  cout << -1 << endl;
  return 0;
}
