#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
int n, k, dis[N];
vector<int> cmp;
void bfs() {
  queue<int> q;
  q.push(0);
  dis[1000] = 0;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto i : cmp) {
      if (!(x + i)) {
        printf("%d\n", dis[x + 1000] + 1);
        exit(0);
      }
      if (x + i > 1000 || x + i < -1000 || dis[x + i + 1000] != -1) continue;
      dis[x + i + 1000] = dis[x + 1000] + 1;
      q.push(x + i);
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0, a; i < k; i++) {
    scanf("%d", &a);
    cmp.push_back(a - n);
  }
  memset(dis, -1, sizeof dis);
  sort(cmp.begin(), cmp.end());
  cmp.resize(unique(cmp.begin(), cmp.end()) - cmp.begin());
  bfs();
  puts("-1");
}
