#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int SS = maxn * 2;
int g[SS][SS];
bool isval(int x) { return (x >= -(maxn - 2) && x <= (maxn - 2)); }
void ad_e(int v, int u) {
  if (isval(u) && isval(v)) {
    u += maxn;
    v += maxn;
    g[u][v] = 1;
  }
}
int dis[SS];
void bfs(int x) {
  memset(dis, 63, sizeof dis);
  dis[x] = 0;
  queue<int> q;
  q.push(x);
  while (q.size()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < SS; i++)
      if (g[v][i] && dis[v] + 1 < dis[i]) {
        dis[i] = dis[v] + 1;
        q.push(i);
      }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  set<int> s;
  int l, n;
  cin >> l >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s.insert(l - x);
  }
  if (s.find(0) != s.end()) {
    cout << 1 << '\n';
    return 0;
  }
  for (auto t : s) {
    for (int i = -maxn; i <= maxn; i++) {
      ad_e(i, i + t);
    }
  }
  bfs(maxn);
  int ans = 2e9;
  for (int i = 0; i < SS; i++) {
    if (g[i][maxn]) ans = min(ans, 1 + dis[i]);
  }
  if (ans >= (int)1e9) ans = -1;
  cout << ans << '\n';
}
