#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k, ma = 1000000, t;
  cin >> n >> k;
  vector<int> q(2017, ma);
  for (int i = 0; i < k; i++) {
    cin >> t;
    q[t - n + 1000] = 1;
  }
  for (int attempt = 0; attempt < 100; attempt++) {
    for (int i = 0; i < 1000; i++) {
      if (q[i] == ma) continue;
      for (int j = 1001; j <= 2000; j++) {
        if (q[j] != ma) {
          q[i + j - 1000] = min(q[i + j - 1000], q[i] + q[j]);
        }
      }
    }
  }
  if (q[1000] == ma)
    cout << -1;
  else
    cout << q[1000];
  return 0;
}
