#include <bits/stdc++.h>
using namespace std;
const int N = 1005, M = 100005, mod = 1e9 + 7;
inline void gmin(int &x, int y) {
  if (x > y) x = y;
}
inline void gmax(int &x, int y) {
  if (x < y) x = y;
}
inline void ch(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
int n, m, k, a[N], d[N << 2];
bool vis[N];
queue<int> q;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    int x;
    scanf("%d", &x);
    if (!vis[x]) a[++m] = x - n;
    vis[x] = 1;
  }
  for (int i = 1; i <= m; i++) d[a[i] + 1000] = 1, q.push(a[i] + 1000);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 1; i <= m; i++)
      if (x + a[i] > 0 && !d[x + a[i]])
        d[x + a[i]] = d[x] + 1, q.push(x + a[i]);
  }
  printf("%d\n", d[1000] ? d[1000] : -1);
  return 0;
}
