#include <bits/stdc++.h>
using namespace std;
void openFile() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
const int maxN = 2e3 + 5;
const int maxM = 1e6 + 5;
const long long INF = 1e3;
int N, K;
bool a[maxN];
int vis[maxN];
void enter() {
  cin >> N >> K;
  for (int i = 1, _b = K; i <= _b; ++i) {
    int x;
    cin >> x;
    a[x - N + INF] = true;
    if (x == N) {
      cout << 1 << endl;
      exit(0);
    }
  }
}
void solve() {
  queue<int> q;
  vis[INF] = 1;
  q.push(INF);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int j = -INF, _b = INF; j <= _b; ++j)
      if (a[j + INF]) {
        int v = u - INF + j;
        if (v == 0) {
          cout << vis[u] << endl;
          return;
        }
        if (abs(v) > INF) continue;
        v = v + INF;
        if (vis[v] == 0) {
          vis[v] = vis[u] + 1;
          q.push(v);
        }
      }
  }
  cout << -1 << endl;
}
int main() {
  openFile();
  enter();
  solve();
  return 0;
}
