#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long BIG = 1446803456761533460LL;
const int Big = 336860180;
const long long int INF = LONG_LONG_MAX;
const long long int adj4[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const long long int adj8[8][2] = {{0, 1},   {0, -1}, {1, 0},  {-1, 0},
                                  {-1, -1}, {1, -1}, {-1, 1}, {1, 1}};
long long int clk_ar[10];
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int powMod(long long int a, long long int b) {
  long long int n = 1;
  long long int p = a;
  while (b > 0) {
    if (b % 2 == 1) {
      n *= p;
      n %= MOD;
    }
    p *= p;
    p %= MOD;
    b /= 2;
  }
  return n;
}
long long int modularInverse(long long int a) { return powMod(a, MOD - 2); }
stringstream sss;
const long long int maxn = 1010;
const long long int maxk = 1000010;
long long int ai[maxk];
queue<long long int> q;
long long int d[maxn * 2];
void MAIN() {
  long long int n, k;
  cin >> n >> k;
  for (long long int i = 0; i < (k); ++i) {
    cin >> ai[i];
  }
  sort(ai, ai + k);
  k = unique(ai, ai + k) - ai;
  for (long long int i = 0; i < (k); ++i) {
    ai[i] -= n;
  }
  memset(d, -1, sizeof d);
  d[0] = 0;
  q.push(0);
  while (!q.empty()) {
    long long int x = q.front();
    q.pop();
    for (long long int i = 0; i < (k); ++i) {
      long long int y = x + ai[i];
      if (y == 0) {
        cout << (d[x] + 1) << '\n';
        return;
      }
      if (d[y] == -1) {
        d[y] = d[x] + 1;
        q.push(y);
      }
    }
  }
  cout << (-1) << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  sss << R"(
501 4
100 300 450 500
    )";
  MAIN();
  return 0;
}
