#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int concen[N], ans[2 * N], n, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  int ai;
  for (int i = 0, _b = k; i < _b; i++) {
    cin >> ai;
    concen[ai] = 1;
  }
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int sum = q.front();
    q.pop();
    for (int i = 0, _b = 1000; i <= _b; i++)
      if (concen[i]) {
        int newSum = sum + (i - n);
        if (newSum < -N || newSum > N || ans[N + newSum]) continue;
        if (!newSum) {
          cout << ans[N + sum] + 1 << endl;
          return 0;
        }
        ans[N + newSum] = ans[N + sum] + 1;
        q.push(newSum);
      }
  }
  cout << -1 << endl;
  return 0;
}
