#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000 + 190;
const int maxSum = 2 * maxN;
const int oo = 0x3c3c3c3c;
int n, k, app[maxN], dd[maxSum];
queue<int> qe;
bool check(int x) {
  if (x > 1000 || x < -1000) return false;
  return true;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; ++i) {
    int a;
    scanf("%d", &a);
    app[a] = 1;
  }
  for (int i = -1000; i <= 1000; ++i) dd[i + 1000] = oo;
  for (int i = 0; i <= 1000; ++i)
    if (app[i] == 1) {
      dd[0 + i - n + 1000] = 1;
      qe.push(i - n);
    }
  while (!qe.empty()) {
    int u = qe.front();
    qe.pop();
    for (int i = 0; i <= 1000; ++i) {
      if (app[i] == 1 && check(u + i - n) == true &&
          dd[u + i - n + 1000] > dd[u + 1000] + 1) {
        qe.push(u + i - n);
        dd[u + i - n + 1000] = dd[u + 1000] + 1;
      }
    }
  }
  if (dd[0 + 1000] == oo)
    cout << -1;
  else
    cout << dd[0 + 1000];
  return 0;
}
