#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int maxn = 1e5 + 10;
const int MOD = 1e9 + 7;
const int inf = 0x3f3f3f3f;
void fre() { freopen("in.txt", "r", stdin); }
queue<int> q;
set<int> st;
int vis[N];
int fun() {
  while (!q.empty()) {
    int tem = q.front();
    q.pop();
    if (tem == 0) return vis[tem + 1000];
    for (auto i : st) {
      int val = tem + i;
      if (val >= -1000 && val <= 1000 && vis[val + 1000] == 0) {
        q.push(val);
        vis[val + 1000] = vis[tem + 1000] + 1;
      }
    }
  }
  return -1;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    int x;
    scanf("%d", &x);
    x -= n;
    st.insert(x);
    q.push(x);
    vis[x + 1000] = 1;
  }
  int ans = fun();
  cout << ans << endl;
  return 0;
}
