#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, c = getchar(), f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
const int BASE = 1000;
int n, k;
bool ok[1005];
bitset<2005> dp[2];
int main() {
  n = read();
  k = read();
  for (int i = 1; i <= k; i++) ok[read()] = 1;
  int now = 1;
  dp[now][BASE] = 1;
  for (int i = 1; i <= 2000; i++) {
    dp[now ^= 1].reset();
    for (int j = 0; j <= 1000; j++)
      if (ok[j]) dp[now] |= (dp[now ^ 1] << j) >> n;
    if (dp[now][BASE]) {
      printf("%d\n", i);
      return 0;
    }
  }
  puts("-1");
  return 0;
}
