#include <bits/stdc++.h>
using namespace std;
long long dist[2005];
int n, k, i, a;
queue<int> q;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (i = 0; i <= 2000; i++) dist[i] = INT_MAX;
  for (i = 1; i <= k; i++) {
    cin >> a;
    dist[a - n + 1000] = 1;
  }
  for (i = 0; i <= 2000; i++)
    if (dist[i] == 1) q.push(i);
  while (q.size()) {
    a = q.front();
    q.pop();
    for (i = 0; i <= 2000; i++)
      if (dist[i] == 1 && dist[a + i - 1000] == INT_MAX)
        q.push(a + i - 1000), dist[a + i - 1000] = dist[a] + 1;
  }
  if (dist[1000] == INT_MAX)
    cout << -1;
  else
    cout << dist[1000];
  return 0;
}
