#include <bits/stdc++.h>
const int maxn = 1000 + 5;
int n;
int k;
int a[maxn * maxn];
int vis[maxn << 2];
inline void BFS() {
  std::queue<int> q;
  for (int i = 1; i <= k; i++) {
    q.push(a[i]);
    vis[a[i] + (2000)] = 1;
  }
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (int i = 1; i <= k; i++) {
      if (a[i] + t >= -2000 && a[i] + t <= 2000 && !vis[a[i] + t + (2000)]) {
        vis[a[i] + t + (2000)] = vis[t + (2000)] + 1;
        q.push(a[i] + t);
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &a[i]);
    a[i] -= n;
  }
  std::sort(a + 1, a + k + 1);
  k = std::unique(a + 1, a + k + 1) - (a + 1);
  BFS();
  if (vis[(2000)])
    printf("%d\n", vis[(2000)]);
  else
    printf("-1\n");
  return 0;
}
