#include <bits/stdc++.h>
using namespace std;
int n, k;
int vis[1010];
int que[1010], tot;
int v[2][1000010];
void go(int *f) {
  memset(f, 63, sizeof v[0]);
  f[0] = 0;
  for (int i = 0; i < 1000000; ++i) {
    if (f[i] > 1000) continue;
    for (int j = 1; j <= tot; ++j) {
      if (i + que[j] > 1000000) break;
      f[i + que[j]] = min(f[i + que[j]], f[i] + 1);
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; ++i) {
    int x;
    scanf("%d", &x);
    vis[x] = 1;
  }
  if (vis[n] == 1) {
    puts("1");
    return 0;
  }
  tot = 0;
  for (int i = n + 1; i <= 1000; ++i) {
    if (vis[i]) que[++tot] = i - n;
  }
  go(v[0]);
  tot = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (vis[i]) que[++tot] = n - i;
  }
  go(v[1]);
  int ans = 1071026353;
  for (int i = 1; i <= 1000000; ++i) {
    ans = min(ans, v[0][i] + v[1][i]);
  }
  printf("%d\n", ans <= 1000 ? ans : -1);
}
