#include <bits/stdc++.h>
const int N = 1e3 + 100;
int n, k;
std::vector<int> vec;
void init() {
  std::cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    int t;
    scanf("%d", &t);
    vec.push_back(t - n);
  }
}
void work() {
  std::sort(vec.begin(), vec.end());
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  static int dist[N << 1];
  const int BASE = 1010;
  std::vector<int> queue;
  std::memset(dist, -1, sizeof(dist));
  for (int i = 0; i < (int)vec.size(); i++) {
    dist[BASE + vec[i]] = 1;
    queue.push_back(BASE + vec[i]);
  }
  for (int l = 0; l < (int)queue.size(); l++) {
    int u = queue[l];
    for (int i = 0; i < (int)vec.size(); i++) {
      int v = u + vec[i];
      if (v >= 0 && v <= BASE + N && dist[v] == -1) {
        dist[v] = dist[u] + 1;
        queue.push_back(v);
      }
    }
  }
  std::cout << dist[BASE] << std::endl;
}
int main() {
  init();
  work();
  return 0;
}
