#include <bits/stdc++.h>
const int N = 1e6 + 5;
int n, k, cnt, A[N];
bool vis[1005];
std::bitset<2018> f[2];
inline int read() {
  int now = 0;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); now = now * 10 + c - '0', c = getchar())
    ;
  return now;
}
int main() {
  n = read(), k = read();
  for (int tmp, i = 1; i <= k; ++i)
    if ((tmp = read()) <= 1000) A[++cnt] = tmp, vis[tmp] = 1;
  f[1][1000] = 1;
  if (cnt < 1000)
    for (int now = 1, las, i = 1; i <= 1000; ++i) {
      las = now, now ^= 1;
      f[now].reset();
      for (int j = 1; j <= cnt; ++j) f[now] |= (f[las] << A[j]) >> n;
      if (f[now][1000]) {
        printf("%d", i);
        return 0;
      }
    }
  else
    for (int now = 1, las, i = 1; i <= 1000; ++i) {
      las = now, now ^= 1;
      f[now].reset();
      for (int j = 0; j <= 1000; ++j)
        if (vis[j]) f[now] |= (f[las] << j) >> n;
      if (f[now][1000]) {
        printf("%d", i);
        return 0;
      }
    }
  printf("-1");
  return 0;
}
