#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
vector<vector<int> > array2_int(int N, int M, int def = 0) {
  return vector<vector<int> >(N, vector<int>(M, def));
}
vector<vector<vector<int> > > array3_int(int N, int M, int K, int def = 0) {
  return vector<vector<vector<int> > >(
      N, vector<vector<int> >(M, vector<int>(K, def)));
}
vector<vector<long long> > array2_ll(int N, int M, long long def = 0) {
  return vector<vector<long long> >(N, vector<long long>(M, def));
}
vector<vector<vector<long long> > > array3_ll(int N, int M, int K,
                                              long long def = 0) {
  return vector<vector<vector<long long> > >(
      N, vector<vector<long long> >(M, vector<long long>(K, def)));
}
template <class T>
void printImpl(const vector<T>& coll) {
  copy(coll.begin(), coll.end(), ostream_iterator<T>(cout, " "));
  cout << endl;
}
template <class T, int N>
void printImpl(T (&coll)[N]) {
  copy(coll, coll + N, ostream_iterator<T>(cout, " "));
  cout << endl;
}
template <class Key, class Value>
void printImpl(const map<Key, Value>& data) {
  typename map<Key, Value>::const_iterator it;
  for (it = data.begin(); it != data.end(); ++it) {
    cout << it->first << ":" << it->second << endl;
  }
}
template <class T>
void printImpl(const T& data) {
  cout << data << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  scanf("%d%d", &N, &K);
  set<int> level1;
  int minA = 1001, maxA = -1;
  for (int i = 0; i < (K); ++i) {
    int a;
    scanf("%d", &a);
    level1.insert(a - N);
    minA = min(minA, a);
    maxA = max(maxA, a);
  }
  if (N < minA || maxA < N) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> A(level1.begin(), level1.end());
  int res = 1;
  set<int> level = level1;
  while (level.count(0) == 0) {
    set<int> nextLevel;
    for (int l : level) {
      for (int a : A) {
        if (-1000 <= l + a && l + a <= 1000) {
          nextLevel.insert(l + a);
        }
      }
    }
    level.swap(nextLevel);
    res++;
  }
  cout << res << endl;
  return 0;
}
