#include <bits/stdc++.h>
using std::queue;
const int N = 1000005;
int v, n, a[N], dis[2005];
queue<int> q;
int main() {
  scanf("%d%d", &v, &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] = a[i] - v;
  std::sort(a + 1, a + n + 1);
  n = std::unique(a + 1, a + n + 1) - a - 1;
  memset(dis, 0x3f, sizeof(dis));
  for (int i = 1; i <= n; i++) q.push(1000 + a[i]), dis[1000 + a[i]] = 1;
  if (dis[1000] == 1) {
    puts("1");
    return 0;
  }
  while (q.size()) {
    int t = q.front();
    q.pop();
    for (int i = 1; i <= n; i++) {
      if (t + a[i] < 0 || t + a[i] > 2000) continue;
      if (t + a[i] == 1000) {
        printf("%d\n", dis[t] + 1);
        return 0;
      }
      if (dis[t + a[i]] > 10000000) {
        dis[t + a[i]] = dis[t] + 1;
        q.push(t + a[i]);
      }
    }
  }
  puts("-1");
}
