#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
bool is[1002];
int n, k, dp[1002], minii, maxii;
int viz[1000002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  int dist = 0;
  vector<int> di;
  for (int i = 1; i <= k; ++i) {
    int nr;
    cin >> nr;
    if (i == 1)
      minii = maxii = nr;
    else {
      minii = min(minii, nr);
      maxii = max(maxii, nr);
    }
    if (!is[nr]) ++dist, di.push_back(nr);
    is[nr] = 1;
    dp[nr] = 1;
  }
  if (n > maxii || n < minii) {
    cout << -1;
    return 0;
  }
  deque<pair<int, int> > d;
  d.push_back({0, 0});
  int ct = 0;
  while (!d.empty()) {
    pair<int, int> x = d[0];
    d.pop_front();
    for (int j = 0; j < dist; ++j) {
      int ne_pos = x.first + di[j];
      if (viz[ne_pos] < x.second + 1) {
        if (ne_pos + 3000 >= (x.second + 1) * n &&
            ne_pos - 3000 <= (x.second + 1) * n) {
          viz[ne_pos] = x.second + 1;
          d.push_back({ne_pos, x.second + 1});
          if (ne_pos == n * (x.second + 1)) {
            cout << x.second + 1;
            return 0;
          }
        }
      }
    }
  }
  return 0;
}
