#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long mod2 = 998244353;
const long long N = 3e3 + 12;
bitset<N> dp[2];
bool a[N];
int n, k, x;
void solve() {
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    cin >> x;
    a[x] = 1;
  }
  dp[0][1000] = 1;
  int no, la;
  no = 0;
  la = 1;
  for (int re = 1; re <= 1000; re++) {
    swap(no, la);
    dp[no].reset();
    for (int i = 0; i <= 1000; i++)
      if (a[i]) dp[no] |= (dp[la] << i) >> n;
    if (dp[no][1000] == 1) {
      cout << re;
      return;
    }
  }
  cout << "-1";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
