#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int n, k;
int a[maxn];
bitset<2010> dp[2];
int main() {
  while (scanf("%d%d", &k, &n) == 2) {
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]), a[i] -= k;
    sort(a, a + n);
    n = unique(a, a + n) - a;
    int t = 1;
    dp[0][1000] = 1;
    for (int i = 1; i <= 1005; ++i) {
      for (int j = 0; j < n; ++j) {
        if (a[j] < 0)
          dp[t] |= dp[1 - t] >> (-a[j]);
        else
          dp[t] |= dp[1 - t] << (a[j]);
      }
      if (dp[t][1000] != 0) {
        cout << i << endl;
        return 0;
      }
      t = 1 - t;
      dp[t].reset();
    }
    printf("-1\n");
  }
  return 0;
}
