#include <bits/stdc++.h>
using namespace std;
vector<int> vt[3005];
inline int bfs() {
  int mark[3005];
  memset((mark), (-1), sizeof((mark)));
  ;
  mark[1005] = 0;
  queue<int> q;
  q.push(1005);
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < (vt[u].size()); i++) {
      int v = vt[u][i];
      if (v == 1005) return mark[u] + 1;
      if (mark[v] == -1) {
        mark[v] = mark[u] + 1;
        q.push(v);
      }
    }
  }
  return -1;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  set<int> s;
  for (int i = 0; i < (k); i++) {
    int x;
    scanf("%d", &x);
    s.insert(x - n);
  }
  set<int>::iterator it;
  vector<int> edge;
  for (it = s.begin(); it != s.end(); it++) {
    edge.push_back(*it);
  }
  for (int i = -1005; i <= 1005; i++) {
    int u = i + 1005;
    for (int j = 0; j < (edge.size()); j++) {
      int v = u + edge[j];
      if (v >= 0 && v <= 2010) vt[u].push_back(v);
    }
  }
  printf("%d\n", bfs());
  return 0;
}
