#include <bits/stdc++.h>   using namespace std;   const int ss = 1000;   int n, k, ans, x;   bool flag1, flag2;   bool a[5000][5000];   int b[1002], tot;   int main() {     scanf( %d%d , &n, &k);     memset(a, false, sizeof(a));     memset(b, false, sizeof(b));     flag1 = flag2 = false;     n += ss;     for (int i = 1; i <= k; ++i) {       scanf( %d , &x);       a[0][x + ss] = true;       if (x + ss > n) flag1 = true;       if (x + ss < n) flag2 = true;     }     tot = 0;     for (int i = 0; i <= 1000 + ss; ++i) {       if (a[0][i]) b[++tot] = i;     }     if (a[0][n])       ans = 1;     else if (flag1 ^ flag2 || (k == 1))       ans = -1;     else       for (int i = 1; i <= 5010; ++i) {         for (int j = 0; j <= 3000; ++j)           if (a[i - 1][j]) {             for (int k = 1; k <= tot; ++k) {               if (j + b[k] - n >= 0 && j + b[k] - n <= 3000) {                 a[i][j + b[k] - n] = true;               }             }           }         if (a[i][n]) {           ans = i + 1;           break;         }       }     cout << ans << endl;     return 0;   }   