#include <bits/stdc++.h>
using namespace std;
bool visit[1001];
int ans[2002];
int n, k;
int to;
int i;
vector<int> vec;
void bfs() {
  for (i = 0; i < 2002; i++) ans[i] = -1;
  queue<int> q;
  q.push(0);
  ans[0] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (i = 0; i < vec.size(); i++) {
      to = v + vec[i];
      if (to == 0) {
        ans[to] = ans[v] + 1;
        cout << ans[to];
        return;
      }
      if (to > 0 && to < 2002 && ans[to] == -1) {
        ans[to] = ans[v] + 1;
        q.push(to);
      }
    }
  }
  cout << -1;
}
int main() {
  for (i = 0; i < 1001; i++) visit[i] = false;
  scanf("%d%d", &n, &k);
  while (k--) {
    int x;
    scanf("%d", &x);
    if (!visit[x]) {
      vec.push_back(x - n);
      visit[x] = true;
    }
  }
  bfs();
}
