#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000 + 10;
int n, k;
bitset<MAX_N * 3> am, nam;
bool has[MAX_N];
int main() {
  cin >> n >> k;
  int minx = MAX_N, maxx = -MAX_N;
  for (int it = (0); it < (k); it++) {
    int x;
    scanf("%d", &x);
    has[x] = 1;
    minx = min(minx, x);
    maxx = max(maxx, x);
  }
  if (minx > n || maxx < n) {
    puts("-1");
    return 0;
  }
  am[MAX_N] = 1;
  for (int t = (0); t < (MAX_N); t++) {
    if (t > 0 && am[MAX_N]) {
      cout << t << endl;
      return 0;
    }
    am = am >> n;
    nam.reset();
    for (int it = (0); it < (MAX_N); it++)
      if (has[it]) nam |= am << it;
    am = nam;
  }
  return 0;
}
