#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const int N = 1e6 + 10;
bool present[2010];
bool vis[2010];
queue<pair<int, int> > q;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  memset(vis, 0, sizeof(vis));
  int ans = 0;
  bool flag1 = false, flag2 = false;
  for (int i = 1; i <= k; ++i) {
    int temp;
    cin >> temp;
    if (temp == n) ans = 1;
    if (temp < n) flag1 = true;
    if (temp > n) flag2 = true;
    present[temp] = true;
  }
  if (ans) {
    cout << 1;
    return 0;
  }
  if (!flag1 or !flag2) {
    cout << -1;
    return 0;
  }
  q.push(make_pair(1000, 0));
  flag1 = false;
  while (!q.empty()) {
    int val = q.front().first;
    int len = q.front().second;
    if (val == 1000 and flag1) {
      cout << len;
      return 0;
    }
    flag1 = true;
    q.pop();
    if (vis[val]) continue;
    vis[val] = true;
    for (int i = 0; i <= 1000; ++i) {
      if (present[i]) {
        if (0 <= val + i - n and 1000 >= val + i - n) {
          q.push(make_pair(val + i - n, len + 1));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
