#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1111;
bool flag[MAXN];
int f[MAXN * 2];
vector<int> g[MAXN * 2];
queue<int> q;
void Update(int &dest, const int &src) {
  if (dest == -1 || src < dest) dest = src;
  return;
}
int main() {
  int n, m, t;
  scanf("%d%d", &n, &m);
  while (m--) scanf("%d", &t), flag[t] = true;
  for (int i = 0; i < MAXN; ++i)
    if (flag[i]) {
      for (int j = 0, k = 0 + i - n; j < MAXN * 2; ++j, ++k)
        if (0 <= k && k < MAXN * 2) g[j].push_back(k);
    }
  memset(f, -1, sizeof(f));
  for (auto &v : g[0 + MAXN]) f[v] = 1, q.push(v);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto &v : g[u])
      if (f[v] == -1 || f[u] + 1 < f[v]) f[v] = f[u] + 1, q.push(v);
  }
  printf("%d\n", f[0 + MAXN]);
  return 0;
}
