#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
const int inf = (int)1e9 + 1;
const long long big = (long long)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
bool g[N][N];
int d[N];
queue<int> q;
void bfs() {
  fill(d, d + N, inf);
  for (int i = 0; i < N; i++)
    if (g[1000][i]) {
      d[i] = 1;
      q.push(i);
    }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v = 0; v < N; v++)
      if (g[u][v] && d[v] == inf) {
        d[v] = d[u] + 1;
        q.push(v);
      }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  int n, k;
  cin >> k >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  n = unique(a, a + n) - a;
  for (int i = 0; i < n; i++) a[i] -= k;
  for (int i = -1000; i < 1000 + 1; i++)
    for (int j = 0; j < n; j++)
      if (i + a[j] >= -1000 && i + a[j] <= 1000)
        g[i + 1000][i + a[j] + 1000] = true;
  bfs();
  cout << (d[1000] != inf ? d[1000] : -1) << "\n";
  return 0;
}
