#include <bits/stdc++.h>
using namespace std;
int INF = 0x3f3f3f3f;
int n, k;
vector<int> a;
int d[160500];
int S = 80000;
int main() {
  scanf("%d", &n), scanf("%d", &k);
  a.resize(k);
  for (int i = 0; i < (int)k; i++) scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  k = distance(a.begin(), unique(a.begin(), a.end()));
  a.resize(k);
  memset(d, -1, sizeof(d));
  queue<int> q;
  int ans = -1;
  for (int i = 0; i < (int)k; i++) {
    q.push(n - a[i]);
    d[n - a[i] + S] = 1;
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (x == 0) {
      ans = d[x + S];
      break;
    }
    for (int i = 0; i < (int)k; i++) {
      int nx = x + n - a[i];
      if (nx > S) continue;
      if (nx < -S) continue;
      if (d[nx + S] != -1) continue;
      d[nx + S] = 1 + d[x + S];
      q.push(nx);
    }
  }
  printf("%d\n", ans);
}
