#include <bits/stdc++.h>
using namespace std;
int dp[3000];
bool apare[1010];
int n, k, c;
int main() {
  ios_base ::sync_with_stdio(0);
  cin >> n >> k;
  while (k--) {
    cin >> c;
    apare[c] = 1;
  }
  queue<int> q;
  vector<int> lungimi;
  for (int i(0); i < 1010; i++) {
    if (!apare[i]) continue;
    int x(n - i + 1500);
    dp[x] = 1;
    q.push(x);
    lungimi.push_back(x - 1500);
  }
  while (!q.empty()) {
    int x(q.front()), t(dp[x]);
    q.pop();
    for (auto i : lungimi) {
      if (x + i >= 0 && x + i < 3000 && !dp[x + i]) {
        dp[x + i] = 1 + t;
        q.push(x + i);
      }
    }
  }
  cout << (dp[1500] ? dp[1500] : -1);
  return 0;
}
