#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
const int maxm = 1e6 + 5;
int n, k, a[maxn];
map<int, int> dp;
vector<int> vec;
void bfs() {
  queue<int> q;
  while (!q.empty()) q.pop();
  for (auto u : vec) {
    dp[u] = 1;
    q.push(u);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (u == 0) {
      printf("%d\n", dp[u]);
      return;
    }
    for (auto v : vec) {
      if (dp[v + u] == 0) {
        dp[v + u] = dp[u] + 1;
        q.push(v + u);
      }
    }
  }
}
void solve() {
  scanf("%d%d", &n, &k);
  int l = 0, r = 0;
  for (int i = 0; i < k; i++) {
    int tmp;
    scanf("%d", &tmp);
    a[tmp] = 1;
    if (tmp <= n) l = 1;
    if (tmp >= n) r = 1;
  }
  if (!l || !r) {
    puts("-1");
    return;
  }
  if (n == 0) {
    puts("1");
    return;
  }
  for (int i = 0; i <= 1000; i++)
    if (a[i]) vec.push_back(n - i);
  bfs();
}
int main() {
  solve();
  return 0;
}
