#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int mxS = 250010;
int dp[2][mxS + 10];
bool exist[1001];
void get(int f, vector<int>& v) {
  dp[f][0] = 0;
  for (int i = 1; i < mxS; i++) {
    dp[f][i] = INT_MAX;
  }
  for (auto p : v) {
    int mx = mxS - p;
    for (int i = 0; i < mx; i++) {
      if (dp[f][i] == INT_MAX) continue;
      dp[f][i + p] = min(dp[f][i + p], dp[f][i] + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(time(NULL));
  int N, K;
  cin >> N >> K;
  vector<int> a(K);
  for (int i = 0; i < K; i++) {
    cin >> a[i];
    exist[a[i]] = true;
  }
  vector<int> up, dw;
  for (int p = 0; p <= 1000; p++) {
    if (!exist[p]) continue;
    if (p == N) {
      cout << "1\n";
      return 0;
    }
    if (p > N) {
      up.push_back(p - N);
    } else {
      dw.push_back(N - p);
    }
  }
  if (up.empty() || dw.empty()) {
    cout << "-1\n";
    return 0;
  }
  get(0, up);
  get(1, dw);
  int res = INT_MAX;
  for (int i = 1; i < mxS; i++) {
    if (dp[0][i] < INT_MAX && dp[1][i] < INT_MAX) {
      res = min(res, dp[0][i] + dp[1][i]);
    }
  }
  if (res == INT_MAX) res = -1;
  cout << res << '\n';
  return 0;
}
