#include <bits/stdc++.h>
using namespace std;
int n, k, ans, a[1000002], f[2002], team[1000002], tot;
bool vis1[2002], vis[2002];
int main() {
  scanf("%d%d", &n, &k);
  bool p1 = 0;
  for (int i = 1; i <= k; i++) {
    int x;
    scanf("%d", &x), x -= n;
    if (vis1[x + 1000]) continue;
    vis1[x + 1000] = 1;
    a[++tot] = x;
  }
  for (int i = 1; i <= tot; i++)
    if (a[i] >= 0) {
      p1 = 1;
      break;
    }
  if (!p1) {
    printf("%d", -1);
    return 0;
  }
  int head = 1, tail = 1;
  team[head] = 0;
  bool p = 0;
  vis[1000] = 1;
  f[1000] = 0;
  while (head <= tail) {
    int x = team[head];
    for (int i = 1; i <= tot; i++) {
      if (!vis[1000 + x + a[i]] && x + a[i] <= 1000 && x + a[i] >= -1000) {
        f[x + a[i] + 1000] = f[1000 + x] + 1;
        vis[1000 + x + a[i]] = 1;
        team[++tail] = x + a[i];
      }
      if (x + a[i] == 0) {
        p = 1;
        ans = f[1000 + x] + 1;
        break;
      }
    }
    if (p) break;
    head++;
  }
  if (p)
    printf("%d", ans);
  else
    printf("%d", -1);
}
