#include <bits/stdc++.h>
using namespace std;
int n, k, vis[3006], in[3006], dp[3006];
vector<int> v;
queue<int> q;
int main() {
  int i, j;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= k; ++i) {
    int x;
    scanf("%d", &x), in[x] = 1;
  }
  memset(dp, 0x3f, sizeof(dp));
  for (i = 0; i <= 1000; ++i) {
    if (in[i]) {
      v.push_back(n - i);
      int x = n - i + 1000;
      dp[x] = 1;
      if (x == 1000) {
        printf("1\n");
        return 0;
      }
      q.push(x);
    }
  }
  for (; !q.empty();) {
    int u = q.front();
    q.pop();
    for (i = 0; i < v.size(); ++i) {
      int x = u + v[i];
      if (x >= 0 && x <= 2000 && dp[x] > dp[u] + 1) {
        dp[x] = dp[u] + 1;
        q.push(x);
      }
    }
  }
  if (dp[1000] >= 100000)
    printf("-1\n");
  else
    printf("%d\n", dp[1000]);
  return 0;
}
