#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e3 + 5;
const int offset = 1e3;
const int INF = 0x3f3f3f3f;
int N, K;
bool has[MAX_N];
int d[MAX_N * 2];
vector<int> G[MAX_N * 2];
int bfs(int s) {
  queue<int> que;
  que.push(s);
  memset(d, 0x3f, sizeof d);
  d[s] = 0;
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int i = 0; i < (int)G[v].size(); ++i) {
      int u = G[v][i];
      if (u == s) {
        return d[v] + 1;
      } else if (d[u] == INF) {
        d[u] = d[v] + 1;
        que.push(u);
      }
    }
  }
  return INF;
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < K; ++i) {
    int a;
    scanf("%d", &a);
    has[a] = 1;
  }
  for (int sum = -1000; sum <= 1000; ++sum) {
    for (int a = 0; a <= 1000; ++a) {
      if (has[a]) {
        int nxt = N - a + sum + offset;
        if (0 <= nxt && nxt <= 2000) {
          G[sum + offset].push_back(nxt);
        }
      }
    }
  }
  int ans = bfs(offset);
  if (ans == INF) {
    puts("-1");
  } else {
    printf("%d\n", ans);
  }
  return 0;
}
