#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1002;
int n, k, a;
int Arr[MAXN];
map<int, bool> Map;
map<int, int> Mark;
vector<int> v;
vector<int> e;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &a);
    if (!Map[a - n]) e.push_back(a - n);
    Map[a - n] = 1;
  }
  int vs = 0;
  v.push_back(0);
  while (vs < v.size()) {
    int u = v[vs++];
    for (int i = 0; i < e.size(); i++)
      if (abs(u + e[i]) < 1001 && !Mark[u + e[i]]) {
        if (-u == e[i]) {
          cout << Mark[u] + 1 << '\n';
          return 0;
        }
        v.push_back(u + e[i]);
        Mark[u + e[i]] = 1 + Mark[u];
      }
  }
  cout << -1 << '\n';
  return 0;
}
