#include <bits/stdc++.h>
using namespace std;
int a[1000005];
vector<int> dp(1005);
queue<int> q;
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> a[i];
    a[i] -= n;
  }
  sort(a, a + k);
  k = unique(a, a + k) - a;
  dp.assign(1005, -1);
  for (int i = 0; i < k; i++) {
    if (a[i] >= 0) {
      dp[a[i]] = 1;
      q.push(a[i]);
    }
  }
  while (!q.empty()) {
    int x = q.front();
    for (int i = 0; i < k; i++) {
      if (x + a[i] >= 0 && x + a[i] <= 1000 && dp[x + a[i]] == -1) {
        dp[x + a[i]] = dp[x] + 1;
        q.push(x + a[i]);
      }
    }
    q.pop();
  }
  cout << dp[0] << endl;
}
