#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 1e3;
const long long MOD = 1000000000 + 7;
const double EPS = 1e-9;
vector<int> g[2 * MAX_SIZE + 1];
set<int> step;
void BFS() {
  vector<int> visited(2 * MAX_SIZE + 1, -1);
  queue<int> q;
  q.push(MAX_SIZE);
  visited[MAX_SIZE] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int a : g[v]) {
      if (visited[a] == -1) {
        q.push(a);
        visited[a] = visited[v] + 1;
      } else if (visited[a] == 0) {
        cout << visited[v] + 1;
        return;
      }
    }
  }
  cout << -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    int a;
    cin >> a;
    step.insert(a - n);
  }
  for (int i = 0; i < 2001; ++i)
    for (int a : step)
      if (i + a < 2001 && i + a >= 0) g[i].push_back(i + a);
  BFS();
  return 0;
}
