func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[1000010], b[1000010];   int f[1000010], g[1000010];   int tmp[1000010];   int ansf[1000010], ansg[1000010];   int main() {     int sv, n, m;     scanf( %d %d , &sv, &n);     int p = 0, q = 0;     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       x -= sv;       if (x == 0) {         puts( 1 );         return 0;       }       int y = abs(x);       if (x < 0)         a[++p] = y;       else         b[++q] = y;     }     if (!p || !q) {       puts( -1 );       return 0;     }     sort(a + 1, a + p + 1);     p = unique(a + 1, a + p + 1) - a - 1;     sort(b + 1, b + q + 1);     q = unique(b + 1, b + q + 1) - b - 1;     n = 0;     for (int i = 1; i <= p; i++) {       f[++n] = a[i];       ansf[a[i]] = 1;     }     for (int i = 1; i < 1005; i++) {       int N = 0;       for (int j = 1; j <= n; j++) {         for (int k = 1; k <= p; k++) {           int x = f[j] + a[k];           if (!ansf[x]) {             ansf[x] = i + 1;             tmp[++N] = x;           }         }       }       n = N;       for (int j = 1; j <= n; j++) f[j] = tmp[j];     }     m = 0;     for (int i = 1; i <= q; i++) {       g[++m] = b[i];       ansg[b[i]] = 1;     }     for (int i = 1; i < 1005; i++) {       int N = 0;       for (int j = 1; j <= m; j++) {         for (int k = 1; k <= q; k++) {           int x = g[j] + b[k];           if (!ansg[x]) {             ansg[x] = i + 1;             tmp[++N] = x;           }         }       }       m = N;       for (int j = 1; j <= m; j++) g[j] = tmp[j];     }     int res = 0x3f3f3f3f;     for (int i = 1; i < 1000010; i++) {       if (ansf[i] && ansg[i]) res = min(res, ansf[i] + ansg[i]);     }     cout << res << endl;   }   