#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int add(int a, int b) {
  long long x = a + b;
  if (x >= 1000000007) x -= 1000000007;
  if (x < 0) x += 1000000007;
  return x;
}
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
long long pw(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int cmmdc(int a, int b) {
  while (b) {
    int c = a % b;
    a = b;
    b = c;
  }
  return a;
}
bool is[1002];
int n, k, dp[1002], minii, maxii;
int calcdp(int nr) {
  if (is[nr]) return dp[nr];
  is[nr] = 1;
  dp[nr] = (1 << 14);
  if (nr == 0) return dp[nr];
  for (int i = minii; i < nr; ++i) {
    calcdp(i);
    if (dp[i] <= dp[nr])
      for (int j = nr + 1; j <= maxii; ++j) {
        int difa = (nr - i) * dp[i];
        int difb = (j - nr) * calcdp(j);
        int x = cmmdc(difa, difb);
        difa /= x;
        difb /= x;
        dp[nr] = min(dp[nr], difb * dp[i] + difa * dp[j]);
      }
  }
  return dp[nr];
}
int viz[1000002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  int dist = 0;
  vector<int> di;
  for (int i = 1; i <= k; ++i) {
    int nr;
    cin >> nr;
    if (i == 1)
      minii = maxii = nr;
    else {
      minii = min(minii, nr);
      maxii = max(maxii, nr);
    }
    if (!is[nr]) ++dist, di.push_back(nr);
    is[nr] = 1;
    dp[nr] = 1;
  }
  if (n > maxii || n < minii) {
    cout << -1;
    return 0;
  }
  if (n == 0) {
    cout << 1;
    return 0;
  }
  deque<pair<int, int> > d;
  d.push_back({0, 0});
  int ct = 0;
  while (!d.empty()) {
    pair<int, int> x = d[0];
    ++ct;
    if (ct >= 2000000) break;
    d.pop_front();
    for (int j = 0; j < dist; ++j) {
      int ne_pos = x.first + di[j];
      if (viz[ne_pos] < x.second + 1) {
        viz[ne_pos] = x.second + 1;
        d.push_back({ne_pos, x.second + 1});
        if (ne_pos == n * (x.second + 1)) {
          cout << x.second + 1;
          return 0;
        }
      }
    }
  }
  calcdp(n);
  if (!is[n] || dp[n] == (1 << 14))
    cout << -1;
  else
    cout << dp[n];
  return 0;
}
