#include <bits/stdc++.h>
using namespace std;
const int NN = 2000, N0 = 1010;
bool flag[N0];
int a[N0 * N0];
struct Bitset {
  unsigned long long b[32];
  int len = 32;
  Bitset() {}
  void set(int i) { b[i >> 6] |= 1ULL << (i & 63); }
  void reset() {
    int i = len;
    while (i--) b[i] = 0;
  }
  bool operator[](int i) { return b[i >> 6] >> (i & 63) & 1; }
  Bitset operator|(Bitset a) {
    Bitset ans;
    int i = len;
    for (ans.len = len; i--; ans.b[i] = b[i] | a.b[i])
      ;
    return ans;
  }
  Bitset operator<<(int k) {
    Bitset ans;
    ans.len = len;
    int m = k >> 6, i = 0;
    k &= 63;
    while (i < m) ans.b[i++] = 0;
    ans.b[m] = b[0] << k;
    while (++i < len) {
      ans.b[i] = b[i - m] << k;
      if (k) ans.b[i] |= b[i - m - 1] >> 64 - k;
    }
    return ans;
  }
  Bitset operator>>(int k) {
    Bitset ans;
    ans.len = len;
    int m = k >> 6, i = len;
    k &= 63;
    while (i-- > len - m) ans.b[i] = 0;
    ans.b[len - m - 1] = b[len - 1] >> k;
    while (i--) {
      ans.b[i] = b[i + m] >> k;
      if (k) ans.b[i] |= b[i + m + 1] << 64 - k;
    }
    return ans;
  }
} s[2];
int main() {
  int k, n, f = 0;
  scanf("%d %d", &k, &n);
  for (; n; n--) {
    int x;
    scanf("%d", &x);
    if (x == k) puts("1"), exit(0);
    flag[x] = 1;
  }
  for (int i = 1001; i--;)
    if (flag[i]) {
      s[f].set(N0 + (a[n++] = k - i));
    }
  for (int i = 1, c; i < NN; i++, f = c) {
    c = f ^ 1;
    if (s[f][N0]) printf("%d", i), exit(0);
    s[c].reset();
    for (int j = n; j--;) {
      if (a[j] > 0)
        s[c] = s[c] | s[f] << a[j];
      else
        s[c] = s[c] | s[f] >> -a[j];
    }
  }
  puts("-1");
}
