#include <bits/stdc++.h>
using namespace std;
using INT = long long;
int N = 1000;
int dp[2020];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < 2020; i++) {
    dp[i] = 0x3f3f3f3f;
  }
  queue<int> q;
  vector<int> tot;
  for (int i = 1; i <= k; i++) {
    int u;
    scanf("%d", &u);
    if (dp[u - n + N] == 0x3f3f3f3f) {
      tot.push_back(u - n);
      dp[u - n + N] = 1;
      q.push(u - n + N);
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int x : tot) {
      if (x + u >= 0 and x + u < 2020 and dp[x + u] > dp[u] + 1) {
        dp[x + u] = dp[u] + 1;
        q.push(x + u);
      }
    }
  }
  if (dp[N] == 0x3f3f3f3f)
    cout << -1 << endl;
  else
    cout << dp[N] << endl;
}
