#include <bits/stdc++.h>
bool atteint[2][2001];
int main() {
  std::vector<int> liste;
  {
    int concentration, nTypes;
    scanf("%d%d", &concentration, &nTypes);
    bool existe[1001];
    for (int i = 0; i <= 1000; ++i) existe[i] = false;
    for (int iType = 0; iType < nTypes; ++iType) {
      int type;
      scanf("%d", &type);
      existe[type] = true;
    }
    for (int i = 0; i <= 1000; ++i)
      if (existe[i]) liste.push_back(i - concentration);
  }
  for (int i = 0; i <= 2000; ++i) atteint[0][i] = false;
  atteint[0][1000] = true;
  for (int iEtape = 1; iEtape <= 2001; ++iEtape) {
    int iMod = iEtape % 2;
    for (int i = 0; i <= 2000; ++i) atteint[iMod][i] = false;
    for (int x : liste)
      for (int i = 0; i <= 2000; ++i)
        if (atteint[1 - iMod][i] && 0 <= i + x && i + x <= 2000)
          atteint[iMod][i + x] = true;
    if (atteint[iMod][1000]) {
      printf("%d\n", iEtape);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
