#include <bits/stdc++.h>
char B[1 << 15], *S = B, *T = B;
using namespace std;
int n, k, ans = 2147483647;
bool u[1001];
int f[2][250001];
inline int read() {
  int x = 0;
  char ch =
      (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF
                                                                     : *S++);
  while (ch < '0' || ch > '9')
    ch = (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF
                                                                        : *S++);
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF
                                                                        : *S++);
  }
  return x;
}
int min(int x, int y) { return x < y ? x : y; }
int main() {
  n = read(), k = read();
  for (register int i = 1; i <= k; i++) u[read()] = 1;
  if (u[n]) {
    puts("1");
    return 0;
  }
  memset(f, 127 / 2, sizeof(f));
  f[0][0] = f[1][0] = 0;
  for (register int i = n + 1; i <= 1000; ++i)
    if (u[i])
      for (register int j = i - n; j <= 250000; ++j)
        if (f[0][j - i + n] < 1000000000)
          f[0][j] = min(f[0][j], f[0][j - i + n] + 1);
  for (register int i = 0; i < n; ++i)
    if (u[i])
      for (register int j = n - i; j <= 250000; ++j)
        if (f[1][j - n + i] < 1000000000)
          f[1][j] = min(f[1][j], f[1][j - n + i] + 1);
  for (register int i = 1; i <= 250000; i++)
    if (f[0][i] < 1000000000 && f[1][i] < 1000000000)
      ans = min(ans, f[0][i] + f[1][i]);
  printf("%d", ans == 2147483647 ? -1 : ans);
  return 0;
}
