#include <bits/stdc++.h>
using namespace std;
int pos[600006];
queue<int> q;
vector<int> adj;
int A(int k) { return k + 2000; }
int main() {
  ios_base::sync_with_stdio(false);
  int n, k, p;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> p;
    if (pos[A(p - n)] == 1) continue;
    adj.push_back((p - n));
    pos[A(p - n)] = 1;
    q.push(A(p - n));
  }
  while (!q.empty()) {
    p = q.front();
    q.pop();
    for (int i = 0; i < adj.size(); i++) {
      int nxt = p + adj[i];
      if (nxt < A(-1000) || nxt > A(1000) || pos[nxt] != 0) continue;
      pos[nxt] = pos[p] + 1;
      q.push(nxt);
    }
  }
  if (pos[A(0)] == 0)
    cout << "-1\n";
  else
    cout << pos[A(0)] << endl;
}
