#include <bits/stdc++.h>
using namespace std;
int n, k;
bool has[1001];
vector<int> edges;
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = -1; ++i < k;) {
    int u;
    cin >> u;
    has[u] = 1;
  }
  bool has_sign[3];
  for (int i = -1; ++i < 1001;)
    if (has[i]) {
      edges.push_back(i - n);
      has_sign[edges.back() < 0 ? 0 : 1 + (edges.back() > 0)] = 1;
    }
  if (has_sign[1]) {
    cout << 1;
    return 0;
  }
  if (!has_sign[0] or !has_sign[2]) {
    cout << -1;
    return 0;
  }
  bitset<(1000100 * 2)> cur;
  cur[((1000100 * 2) / 2)] = 1;
  for (int i = 0; i++ < 1001;) {
    bitset<(1000100 * 2)> new_mask;
    for (auto e : edges) new_mask |= e >= 0 ? cur << e : cur >> (-e);
    if (new_mask[((1000100 * 2) / 2)]) {
      cout << i;
      return 0;
    }
    cur = move(new_mask);
  }
  assert(false);
  return 0;
}
