#include <bits/stdc++.h>
using namespace std;
int n, k;
const int maxn = 1e6 + 7;
int a[maxn];
vector<int> v;
map<int, int> dp[2003];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &a[i]);
    a[i] -= n;
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  dp[0][0] = 1;
  map<int, int>::iterator it;
  for (int i = 1; i <= 1002; i++) {
    for (it = dp[i - 1].begin(); it != dp[i - 1].end(); it++) {
      for (int j = 0; j < v.size(); j++) {
        if (abs(it->first + v[j]) > 1000) continue;
        dp[i][it->first + v[j]] = 1;
      }
    }
    if (dp[i].count(0)) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
}
