#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 7;
const int INF = 1e9 + 7;
int n, k, cnt, cur;
int vis[MAXN];
int a[MAXN];
map<int, int> dis;
int ans = INF;
void bfs() {
  dis.clear();
  queue<int> q;
  dis[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int fr = q.front();
    q.pop();
    int tr;
    for (int i = 1; i <= cnt; i++) {
      tr = fr + a[i];
      if (abs(tr) >= 0 && abs(tr) <= 1000) {
        if (dis.count(tr)) {
          if (!tr) {
            ans = dis[fr] + 1;
            return;
          }
        } else {
          dis[tr] = dis[fr] + 1;
          q.push(tr);
        }
      }
    }
  }
}
int main() {
  int ta;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &ta);
    if (!vis[ta]) {
      a[++cnt] = n - ta;
      vis[ta] = 1;
    }
  }
  bfs();
  if (ans == INF)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
