func_code_string: #include <bits/stdc++.h>   using namespace std;   long long me[10000][1001];   long long n, m;   long long d[10000];   long long g, r;   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> n >> m;     for (long long i = 0; i < m; i++) cin >> d[i];     sort(d, d + m);     cin >> g >> r;     queue<pair<long long, long long> > mq[2];     mq[1].push(pair<long long, long long>(0, g));     me[0][g] = 1;     int ini = 1;     while (!mq[0].empty() || !mq[1].empty()) {       while (!mq[ini % 2].empty()) {         pair<long long, long long> t = mq[ini % 2].front();         mq[ini % 2].pop();         long long i = t.first;         long long j = t.second;         long long np = me[i][j];         if (np == ini) {           if (j == 0) np++, j = g;           if (i && d[i] - d[i - 1] <= j &&               (me[i - 1][j - (d[i] - d[i - 1])] == 0 ||                me[i - 1][j - (d[i] - d[i - 1])] > np)) {             me[i - 1][j - (d[i] - d[i - 1])] = np;             mq[np % 2].push(                 pair<long long, long long>(i - 1, j - (d[i] - d[i - 1])));           }           if (i < m - 1 && d[i + 1] - d[i] <= j &&               (me[i + 1][j - (d[i + 1] - d[i])] == 0 ||                me[i + 1][j - (d[i + 1] - d[i])] > np)) {             me[i + 1][j - (d[i + 1] - d[i])] = np;             mq[np % 2].push(                 pair<long long, long long>(i + 1, j - (d[i + 1] - d[i])));           }         }       }       ini++;     }     long long res = -1;     for (int i = 0; i <= g; i++) {       if (me[m - 1][i]) {         long long can = (me[m - 1][i] - 1) * (g + r) + g - i;         if (res == -1 || can < res) res = can;       }     }     cout << res << endl;     return 0;   }   