#include <bits/stdc++.h>
using namespace std;
const int cas = 1000;
int m, n;
bool a[1005];
bitset<2020> f[2005];
int main() {
  while (scanf("%d%d", &m, &n) != EOF) {
    memset(a, false, sizeof(a));
    for (int i = 0; i <= 2000; i++) f[i].reset();
    for (int i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      a[x] = 1;
    }
    bool flag = 0;
    f[0][cas] = 1;
    for (int i = 1; i <= 2000; i++) {
      for (int j = 0; j <= 1000; j++)
        if (a[j]) {
          f[i] |= (f[i - 1] << j) >> m;
        }
      if (f[i][cas]) {
        cout << i << endl;
        flag = 1;
        break;
      }
    }
    if (!flag) cout << "-1" << endl;
  }
  return 0;
}
