#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 1e9;
using graph = vector<vector<int>>;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int const MAX_M = 2000;
  int const offset = 1000;
  vector<bool> ok(MAX_M + 1);
  vector<int> d(MAX_M + 1, INF);
  for (int i = 0; i < k; ++i) {
    int x;
    scanf("%d", &x);
    x = x - n + offset;
    ok[x] = d[x] = 1;
  }
  queue<int> que;
  for (int i = 0; i <= MAX_M; ++i) {
    if (ok[i]) {
      que.push(i);
    }
  }
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    for (int i = 0; i <= MAX_M; ++i) {
      if (!ok[i]) {
        continue;
      }
      int next = now + i - offset;
      if (next < 0 || MAX_M < next || d[next] != INF) {
        continue;
      }
      d[next] = d[now] + 1;
      que.push(next);
    }
  }
  if (d[offset] == INF) {
    printf("-1\n");
  } else {
    printf("%d\n", d[offset]);
  }
}
