#include <bits/stdc++.h>
using namespace std;
int a[1000005], q[20000010], ans[20000010];
bool f[1000005];
int main() {
  int n, k;
  int ja = 1005;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) scanf("%d", &a[i]);
  sort(a + 1, a + k + 1);
  k = unique(a + 1, a + k + 1) - a - 1;
  for (int i = 1; i <= k; i++) a[i] -= n;
  if (a[1] * a[k] > 0) {
    printf("-1\n");
    return 0;
  }
  int s = 1, t = 1;
  for (int i = 1; i <= k; i++) {
    q[t++] = a[i];
    ans[a[i] + ja] = 1;
    f[a[i] + ja] = 1;
  }
  while (s < t && !f[ja]) {
    for (int i = 1; i <= k; i++) {
      if (abs(q[s] + a[i]) <= ja && !f[q[s] + a[i] + ja]) {
        q[t++] = q[s] + a[i];
        f[q[s] + a[i] + ja] = 1;
        ans[q[s] + a[i] + ja] = ans[q[s] + ja] + 1;
      }
    }
    s++;
  }
  printf("%d\n", ans[ja]);
}
