#include <bits/stdc++.h>
using namespace std;
int n, k, dp[1021], mn, mx;
bool done[1021];
int main() {
  mn = 1021, mx = -1;
  for (int i = 0; i < 1021; i++) dp[i] = 1021;
  scanf("%d%d", &n, &k);
  while (k--) {
    int ai;
    scanf("%d", &ai);
    dp[ai] = 1;
    mn = min(mn, ai);
    mx = max(mx, ai);
  }
  if (n < mn or n > mx) {
    puts("-1");
    exit(0);
  }
  for (int i = 0; i < 1021; i++) {
    int bst = -1;
    for (int j = 0; j < 1021; j++)
      if (not done[j]) {
        if (bst == -1 or dp[j] < dp[bst]) bst = j;
      }
    if (bst == -1) break;
    done[bst] = true;
    for (int j = 0; j < 1021; j++) {
      int nxt = bst + j - n;
      if (nxt < 0 or nxt >= 1021) continue;
      dp[nxt] = min(dp[nxt], dp[bst] + dp[j]);
    }
  }
  printf("%d\n", dp[n]);
}
