#include <bits/stdc++.h>
using namespace std;
long long modpow(long long b, long long e, long long mod) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}
int n, k;
set<int> W;
const int N = 2020;
int dist[N][N];
vector<int> g[N];
bool ok[N];
int32_t main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < (k); ++i) {
    int x;
    scanf("%d", &x);
    ok[x] = true;
  }
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (N); ++j) dist[i][j] = INT_MAX / 3;
  for (int i = 0; i < (N); ++i) {
    for (int j = 0; j <= 1000; j++) {
      if (!ok[j]) continue;
      int w = j - n;
      if ((i + w) < N && (i + w) >= 0) g[i].push_back(i + w);
    }
  }
  for (int i = 1005; i < (1009); ++i) {
    queue<pair<int, int> > q;
    q.push({i, 0});
    while (!q.empty()) {
      pair<int, int> u = q.front();
      q.pop();
      for (auto w : g[u.first]) {
        if (dist[i][w] > u.second + 1) {
          dist[i][w] = u.second + 1;
          q.push({w, dist[i][w]});
        }
      }
    }
  }
  int ans = INT_MAX;
  for (int i = 0; i < (N); ++i) ans = min(ans, dist[i][i]);
  if (ans >= INT_MAX / 3)
    puts("-1");
  else
    printf("%d\n", ans);
}
