#include <bits/stdc++.h>
using namespace std;
set<int> s;
queue<int> q;
map<int, int> imap;
set<int>::iterator it;
int main() {
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) {
    int k;
    scanf("%d", &k);
    s.insert(k - n);
    if (imap[k - n] == 0) {
      q.push(k - n);
    }
    imap[k - n] = 1;
  }
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (it = s.begin(); it != s.end(); it++) {
      int x = *it;
      if (t + x <= 1000 && t + x >= -1000) {
        if (imap[t + x] == 0) {
          imap[t + x] = 1 + imap[t];
          q.push(t + x);
        }
      }
    }
  }
  if (imap[0]) {
    cout << imap[0] << endl;
  } else {
    cout << -1 << endl;
  }
}
