#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 14, tof = 1e3 + 1;
int n, m, a[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  bitset<maxn> cur;
  bool le = 0, ge = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    cur[a[i]] = 1;
    le |= a[i] <= n;
    ge |= a[i] >= n;
  }
  sort(a, a + m);
  m = unique(a, a + m) - a;
  if (!le || !ge) return cout << "-1\n", 0;
  for (int i = 1; i < tof; i++) {
    if (cur[i * n]) return cout << i << '\n', 0;
    bitset<maxn> nxt;
    for (int i = 0; i < m; i++) nxt |= cur << a[i];
    cur = nxt;
  }
}
