#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int MAXN = 1020;
const int inf = 0x3f3f3f3f;
int dp[2 * MAXN];
bool vis[2 * MAXN];
bool st[2 * MAXN];
vector<int> q;
int main() {
  ios::sync_with_stdio(false);
  ll kk, n, g;
  int temp;
  while (cin >> kk >> n) {
    memset(dp, inf, sizeof dp);
    memset(st, false, sizeof st);
    q.clear();
    for (int i = 0; i < n; i++) {
      cin >> temp;
      temp -= kk - MAXN;
      if (temp >= 2 * MAXN || temp < 0) continue;
      st[temp] = true;
      dp[temp] = 1;
    }
    for (int i = 0; i < 2 * MAXN; i++) {
      if (st[i]) q.push_back(i);
    }
    int j, cnt = -1;
    while (cnt++ != q.size()) {
      j = q[cnt];
      for (int k = 0; k < 2 * MAXN; k++) {
        if (st[k]) {
          temp = j + k - MAXN;
          if (temp < 2 * MAXN && temp >= 0 && dp[temp] > dp[j] + 1) {
            dp[temp] = dp[j] + 1;
            q.push_back(temp);
          }
        }
      }
    }
    if (dp[MAXN] != inf)
      cout << dp[MAXN] << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
