#include <bits/stdc++.h>
using namespace std;
bool testando = 0;
bool can[1005];
int dp[2005];
const int inf = 1e9;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    can[x] = true;
  }
  for (int i = 0; i <= 2000; i++) dp[i] = inf;
  vector<int> a;
  queue<int> q;
  for (int i = 0; i <= 1000; i++)
    if (can[i]) {
      int x = i - n + 1000;
      dp[x] = 1;
      a.push_back(x - 1000);
      q.push(x);
    }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < a.size(); i++) {
      int y = a[i];
      if (x + y <= 2000 && x + y >= 0 && dp[x + y] > dp[x] + 1) {
        dp[x + y] = dp[x] + 1;
        q.push(x + y);
      }
    }
  }
  if (dp[1000] == inf)
    cout << -1 << endl;
  else
    cout << dp[1000] << endl;
}
