#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  cout << '(' << p.first << ' ' << p.second << ')';
  return os;
}
template <typename T>
void dpite(T a, T b) {
  return;
}
template <typename T>
void pite(T a, T b) {
  for (T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite;
  cout << '\n';
}
template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void ios_init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
}
template <typename T>
long long gcd(T x, T y) {
  return y == 0 ? x : gcd(y, x % y);
}
template <typename T>
long long lcm(T x, T y) {
  return x / gcd(x, y) * y;
}
int main() {
  ios_init();
  int n;
  int k;
  while (cin >> n >> k) {
    set<int> a;
    for (int i = (0); i < (k); ++i) {
      int in;
      cin >> in;
      a.insert(in);
    }
    const int size = 2048;
    const int mi = size / 2;
    bitset<size> bs;
    for (auto&& e : a) {
      int num = e - n;
      true;
      bs[mi + num] = true;
    }
    for (int d = (1); d < (size + 10); ++d) {
      if (bs[mi]) {
        cout << d << '\n';
        break;
      }
      bitset<size> nbs;
      for (auto&& e : a) {
        int num = e - n;
        if (num < 0) {
          nbs |= bs >> (-num);
        } else {
          nbs |= bs << num;
        }
      }
      swap(nbs, bs);
    }
    if (!bs[mi]) cout << -1 << '\n';
    true;
  }
  return 0;
}
