#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000;
int dp[MAXN];
int a[1010];
int b[1010];
int main() {
  int n, k, t;
  scanf("%d%d", &n, &k);
  memset(dp, 0x7f, sizeof(dp));
  for (int i = 1; i <= k; ++i) {
    scanf("%d", &t);
    t = t - n;
    if (dp[n + t] > 1000000)
      dp[n + t] = 1;
    else
      continue;
    if (t == 0) {
      printf("1");
      return 0;
    }
    if (t < 0)
      a[++a[0]] = t;
    else
      b[++b[0]] = t;
  }
  for (int k = 1; k <= 1000; ++k) {
    int bs = b[0], as = a[0];
    for (int i = 1; i <= bs; ++i) {
      for (int j = 1; j <= as; ++j) {
        int tmp = b[i] + a[j];
        if (dp[n + tmp] > 100000) {
          if (tmp > 0)
            b[++b[0]] = tmp;
          else
            a[++a[0]] = tmp;
        }
        if (dp[n + b[i]] + dp[n + a[j]] < dp[n + tmp]) {
          dp[n + tmp] = dp[n + b[i]] + dp[n + a[j]];
          if (tmp == 0) {
            printf("%d", dp[n + tmp]);
            return 0;
          }
        }
      }
    }
  }
  printf("-1");
  return 0;
}
