#include <bits/stdc++.h>
using namespace std;
bitset<2001> dp[2];
bool a[1100] = {};
int n, k;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    int t;
    scanf("%d", &t);
    a[t] = 1;
  }
  dp[0][1000] = 1;
  int no, la;
  no = 0;
  la = 1;
  int re;
  for (re = 1; re <= 1000; re++) {
    swap(no, la);
    dp[no].reset();
    for (int i = 0; i <= 1000; i++) {
      if (a[i]) dp[no] |= (dp[la] << i) >> n;
    }
    if (dp[no][1000] == 1) {
      printf("%d\n", re);
      return 0;
    }
  }
  puts("-1");
  return 0;
}
