#include <bits/stdc++.h>
using namespace std;
vector<int> a;
bool c[2005];
int n, k, f[2][2005];
int opt(int x, int y) {
  if (x == -1) return y;
  if (y == -1) return x;
  return min(x, y);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    x -= n;
    c[x + 1000] = 1;
  }
  memset(f[0], -1, sizeof f[0]);
  for (int i = 0; i <= 2000; i++)
    if (c[i]) {
      if (i == 1000) {
        cout << "1\n";
        return 0;
      }
      a.push_back(i);
      f[0][i] = 1;
    }
  for (int t = 1;; t++) {
    int cur = t & 1, pre = 1 - cur;
    memset(f[cur], -1, sizeof f[cur]);
    bool found = 0;
    for (int i = 0; i <= 2000; i++) {
      if (f[pre][i] == -1) continue;
      int j = i - 1000;
      for (int _ = 0; _ < int(a.size()); _++) {
        int v = a[_] - 1000;
        if (j + v + 1000 >= 0 && j + v + 1000 <= 2000) {
          f[cur][j + v + 1000] = opt(f[cur][j + v + 1000], f[pre][i] + 1);
          if (f[cur][j + v + 1000] != f[pre][j + v + 1000]) found = 1;
        }
      }
    }
    if (f[cur][1000] != -1) {
      cout << f[cur][1000] << "\n";
      return 0;
    }
    if (!found) break;
  }
  cout << "-1\n";
  return 0;
}
