#include <bits/stdc++.h>
using namespace std;
int n, k, mx;
int a[4000400], q[4000400], dis[2005];
bool vis[2005];
int head[2005], edgenum;
struct Edge {
  int to, nxt;
} edge[4000400];
inline void add(int u, int v) {
  edge[++edgenum].to = v;
  edge[edgenum].nxt = head[u];
  head[u] = edgenum;
}
inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = 10 * x + c - '0';
    c = getchar();
  }
  x *= f;
}
inline void build() {
  for (int i = -1000; i <= 1000; i++)
    for (int j = 1; j <= k; j++)
      if (i + a[j] >= -1000 && i + a[j] <= 1000) add(i + 1000, i + a[j] + 1000);
}
inline int bfs() {
  memset(dis, 0x3f3f3f3f, sizeof(dis));
  int f = 0, r = 1;
  q[f] = 1000;
  dis[1000] = 0;
  while (f != r) {
    int u = q[f++];
    for (int i = head[u]; i != 0; i = edge[i].nxt)
      if (dis[edge[i].to] > dis[u] + 1) {
        dis[edge[i].to] = dis[u] + 1;
        q[r++] = edge[i].to;
      } else if (edge[i].to == 1000)
        return dis[u] + 1;
  }
  return -1;
}
int main() {
  read(n);
  read(k);
  for (int i = 1; i <= k; i++) read(a[i]);
  for (int i = 1; i <= k; i++) vis[a[i]] = 1;
  int l = 0;
  for (int i = 0; i <= 1000; i++)
    if (vis[i]) a[++l] = i;
  for (int i = 1; i <= l; i++) a[i] -= n;
  k = l;
  build();
  printf("%d", bfs());
  return 0;
}
