func_code_string: #include <bits/stdc++.h>   using namespace std;   long long R[10 << 10][1 << 10];   int A[10 << 10];   int n, m, g, r;   int main() {     cin >> n >> m;     int i, j;     for (i = (0); i < (m); ++i) cin >> A[i];     cin >> g >> r;     sort(A, A + m);     for (i = (0); i < (m); ++i)       for (j = (0); j < (g + 1); ++j) R[i][j] = (1LL << 60);     R[0][0] = 0;     deque<pair<long long, pair<int, int>>> q;     q.push_front(make_pair(R[0][0], pair<int, int>(0, 0)));     long long res = (1LL << 60);     while (!q.empty()) {       int pos = q.front().second.first;       int rem = q.front().second.second;       long long val = q.front().first;       q.pop_front();       if (R[pos][rem] != val) continue;       if (pos == m - 1) res = min(res, val);       int p[] = {pos - 1, pos + 1};       int d[] = {pos == 0 ? -1 : A[pos] - A[pos - 1],                  pos + 1 == m ? -1 : A[pos + 1] - A[pos]};       for (i = (0); i < (2); ++i)         if (0 <= p[i] && p[i] < m && d[i] > 0 && rem + d[i] <= g) {           int pos2 = p[i];           int rem2 = rem + d[i];           int val2 = val + d[i];           if (R[pos2][rem2] > val2) {             R[pos2][rem2] = val2;             q.push_front(make_pair(R[pos2][rem2], pair<int, int>(pos2, rem2)));           }         }       if (rem == g) {         int pos2 = pos;         int rem2 = 0;         int val2 = val + r;         if (R[pos2][rem2] > val2) {           R[pos2][rem2] = val2;           q.push_back(make_pair(R[pos2][rem2], pair<int, int>(pos2, rem2)));         }       }     }     if (res == (1LL << 60)) res = -1;     cout << res << endl;     return 0;   }   