#include <bits/stdc++.h>
using namespace std;
bool a[1100];
int n, k;
int d[3100];
bool v[3100];
vector<int> u;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    int t;
    scanf("%d", &t);
    if (a[t] == 0) {
      u.push_back(t - n);
      a[t] = 1;
    }
  }
  queue<int> q;
  q.push(1000);
  v[1000] = 1;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (auto &i : u) {
      if (t + i < 0 || t + i > 2000) continue;
      if (t + i == 1000) {
        printf("%d\n", d[t] + 1);
        return 0;
      }
      if (v[t + i] == 0) {
        d[t + i] = d[t] + 1;
        v[t + i] = 1;
        q.push(t + i);
      }
    }
  }
  puts("-1");
  return 0;
}
