#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const int MN = 2e3 + 10, MK = 1e6 + 10, MV = 3e5 + 10;
int a[MN], b[MN], arr[MK], n, k, A, B;
int dpA[MV], dpB[MV];
int mx[2];
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < k; ++i) cin >> arr[i], arr[i] -= n;
  sort(arr, arr + k);
  k = unique(arr, arr + k) - arr;
  mx[0] = mx[1] = -INF;
  for (int i = 0; i < k; ++i)
    if (arr[i] < 0)
      a[A++] = abs(arr[i]), mx[0] = max(mx[0], a[A - 1]);
    else if (arr[i] > 0)
      b[B++] = arr[i], mx[1] = max(mx[1], b[B - 1]);
    else
      return cout << 1 << endl, 0;
  if (mx[0] == -INF || mx[1] == -INF) return cout << -1 << endl, 0;
  for (int i = 1; i < MV; ++i) dpA[i] = dpB[i] = INF;
  int res = INF;
  for (int i = 0; i < MV; ++i) {
    if (i && dpA[i] < INF && dpB[i] < INF) res = min(res, dpA[i] + dpB[i]);
    for (int j = 0; j < A; ++j)
      if (i + a[j] < MV) dpA[i + a[j]] = min(dpA[i] + 1, dpA[i + a[j]]);
    for (int j = 0; j < B; ++j)
      if (i + b[j] < MV) dpB[i + b[j]] = min(dpB[i] + 1, dpB[i + b[j]]);
  }
  cout << (res >= INF ? -1 : res) << endl;
  return 0;
}
