#include <bits/stdc++.h>
using namespace std;
bool type[1001];
const int offset = 1001;
int d[2006];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    int x;
    cin >> x;
    type[x] = 1;
  }
  for (auto &x : d) x = -1;
  queue<int> Q;
  Q.push(0 + offset);
  d[0 + offset] = 0;
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    for (int i = 0; i <= 1000; ++i)
      if (type[i]) {
        int nxt = x + i - n;
        if (nxt == 0 + offset) {
          cout << d[x] + 1 << endl;
          return 0;
        }
        if (d[nxt] != -1) continue;
        d[nxt] = d[x] + 1;
        Q.push(nxt);
      }
  }
  cout << -1 << endl;
  return 0;
}
