#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  long long is_there[1001];
  for (int i = 0; i < 1001; i++) {
    is_there[i] = 0;
  }
  for (int i = 0; i < k; i++) {
    long long input;
    cin >> input;
    is_there[input] = 1;
  }
  vector<int> distinct;
  for (int i = 0; i < 1001; i++) {
    if (is_there[i] == 1) {
      distinct.push_back(i);
    }
  }
  vector<int> distance;
  for (int i = 0; i < distinct.size(); i++) {
    distance.push_back(distinct[i] - n);
  }
  long long reached[1001];
  for (int i = 0; i < 1001; i++) {
    reached[i] = -1;
  }
  queue<int> q;
  for (int i = 0; i < distinct.size(); i++) {
    q.push(distinct[i]);
    reached[distinct[i]] = 1;
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int j = 0; j < distance.size(); j++) {
      int v = u + distance[j];
      if (0 <= v && v <= 1000 && reached[v] == -1) {
        reached[v] = reached[u] + 1;
        q.push(v);
      }
    }
  }
  cout << reached[n] << endl;
}
