#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
int a[N], c[N], n, k;
int main() {
  cin >> n >> k;
  queue<pair<int, int>> q;
  for (int i = 0, j; i < k; i++) {
    scanf("%d", &j), j += 1000 - n;
    if (!c[j]) c[j] = a[j] = 1, q.push({j, 1});
  }
  while (!q.empty()) {
    int u = q.front().first, d = q.front().second;
    q.pop();
    if (u == 1000) return cout << d << endl, 0;
    for (int i = 0, j; i < N; i++)
      if (c[i])
        if (0 <= (j = i + u - 1000) && j < N && !a[j])
          a[j] = 1, q.push({j, d + 1});
  }
  puts("-1");
  return 0;
}
