#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int gcd(int a, int b) {
  if (b > a) swap(a, b);
  if (a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}
int x1, x2, z;
vector<unordered_map<int, int>> dp;
int rec(vector<int> &data, int s, int p) {
  if (s == 0) {
    return 0;
  }
  if (p == data.size()) {
    return INF;
  }
  if (s < x1) return INF;
  if (s > 0) return INF;
  if (dp[p].count(s)) {
    return dp[p][s];
  }
  int res = rec(data, s, p + 1);
  for (int i = 1; i <= z; ++i) {
    if (i >= res) break;
    int c = i + rec(data, s + i * data[p], p + 1);
    res = min(c, res);
  }
  dp[p][s] = res;
  return res;
}
int main(int argc, const char *argv[]) {
  std::ios::sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  vector<bool> was(1001, false);
  vector<int> data;
  dp.resize(1001);
  data.reserve(1000);
  for (int i = 0; i < n; ++i) {
    int v;
    cin >> v;
    if (was[v]) continue;
    was[v] = true;
    data.push_back(v);
  }
  for (int i = 0; i < data.size(); ++i) {
    if (data[i] == k) {
      cout << "1" << endl;
      return 0;
    }
    data[i] = data[i] - k;
  }
  int res = INF;
  sort(data.begin(), data.end());
  for (int i = 0; i < data.size(); ++i) {
    for (int j = i + 1; j < data.size(); ++j) {
      int a = data[i];
      int b = data[j];
      if (a < 0 && 0 < b) {
        int g = gcd(abs(a), b);
        int c = abs(a) / g + b / g;
        res = min(res, c);
      }
    }
  }
  if (res == INF) {
    cout << -1 << endl;
    return 0;
  }
  z = res;
  x1 = -data.back() * res;
  x2 = -data.front() * res;
  for (int i = 0; i < data.size(); ++i) {
    int c = 1 + rec(data, data[i], 0);
    res = min(res, c);
  }
  cout << res << endl;
  return 0;
}
