#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
bitset<N * 2> dp[2];
bool g[N];
int val[N];
int main() {
  int j, n, k, i, u, sz = 0;
  cin >> n >> k;
  for (i = 0; i < k; ++i) scanf("%d", &u), g[u] = 1;
  for (i = 0; i < N; ++i)
    if (g[i]) val[sz++] = i;
  int pos = 0;
  dp[pos][1000] = 1;
  for (i = 1; i < N; ++i) {
    pos ^= 1;
    dp[pos].reset();
    for (j = 0; j < sz; ++j) {
      dp[pos] |= (dp[pos ^ 1] << val[j]) >> n;
    }
    if (dp[pos][1000]) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
