#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
const int INF = 0x3f3f3f3f;
vector<int> a;
bool vis[MAXN];
bitset<MAXN * 2> dp[2];
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    X = (X << 3) + (X << 1) + (ch ^ 48);
    ch = getchar();
  }
  return w ? -X : X;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    int x = read();
    if (!vis[x]) {
      vis[x] = true;
      a.push_back(x);
    }
  }
  int now = 1, last = 0;
  dp[now][1000] = 1;
  for (int i = 1; i <= 2000; i++) {
    swap(now, last);
    dp[now].reset();
    for (int j = 0; j < a.size(); j++) {
      dp[now] |= (dp[last] << a[j]) >> n;
      if (dp[now][1000]) {
        cout << i << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}
