#include <bits/stdc++.h>
using namespace std;
int a[10005];
int n, m;
int dp[10005][1005];
bool on[10005][1005];
int r, g;
int inf = 1e9;
int mi = 1e9;
void fnd(int i, int mod) {
  deque<pair<int, pair<int, int> > > q;
  q.push_front(make_pair(0, make_pair(i, mod)));
  while (q.empty() == 0) {
    int j;
    pair<int, pair<int, int> > tmp;
    tmp = q.front();
    q.pop_front();
    if (on[tmp.second.first][tmp.second.second]) continue;
    on[tmp.second.first][tmp.second.second] = 1;
    dp[tmp.second.first][tmp.second.second] = tmp.first;
    if (tmp.second.second == 0) tmp.first += g;
    for (j = tmp.second.first + 1; j < m && j < tmp.second.first + 2; j++) {
      if (abs(a[j] - a[tmp.second.first]) + tmp.second.second <= r &&
          on[j][(tmp.second.second + abs(a[j] - a[tmp.second.first])) % r] ==
              0) {
        if (dp[j][(tmp.second.second + abs(a[j] - a[tmp.second.first])) % r] >
            tmp.first + abs(a[j] - a[tmp.second.first])) {
          if (tmp.second.second == 0)
            q.push_back(make_pair(
                tmp.first + abs(a[j] - a[tmp.second.first]),
                make_pair(
                    j, (tmp.second.second + abs(a[j] - a[tmp.second.first])) %
                           r)));
          else
            q.push_front(make_pair(
                tmp.first + abs(a[j] - a[tmp.second.first]),
                make_pair(
                    j, (tmp.second.second + abs(a[j] - a[tmp.second.first])) %
                           r)));
          dp[j][(tmp.second.second + abs(a[j] - a[tmp.second.first])) % r] =
              tmp.first + abs(a[j] - a[tmp.second.first]);
        }
      } else if (abs(a[j] - a[tmp.second.first]) + tmp.second.second > r)
        break;
    }
    for (j = tmp.second.first - 1; j >= 0 && j > tmp.second.first - 2; j--) {
      if (abs(a[j] - a[tmp.second.first]) + tmp.second.second <= r &&
          on[j][(tmp.second.second + abs(a[j] - a[tmp.second.first])) % r] ==
              0) {
        if (dp[j][(tmp.second.second + abs(a[j] - a[tmp.second.first])) % r] >
            tmp.first + abs(a[j] - a[tmp.second.first])) {
          if (tmp.second.second == 0)
            q.push_back(make_pair(
                tmp.first + abs(a[j] - a[tmp.second.first]),
                make_pair(
                    j, (tmp.second.second + abs(a[j] - a[tmp.second.first])) %
                           r)));
          else
            q.push_front(make_pair(
                tmp.first + abs(a[j] - a[tmp.second.first]),
                make_pair(
                    j, (tmp.second.second + abs(a[j] - a[tmp.second.first])) %
                           r)));
          dp[j][(tmp.second.second + abs(a[j] - a[tmp.second.first])) % r] =
              tmp.first + abs(a[j] - a[tmp.second.first]);
        }
      } else if (abs(a[j] - a[tmp.second.first]) + tmp.second.second > r)
        break;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int i, j;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a[i];
  }
  sort(a, a + m);
  cin >> r >> g;
  for (i = 0; i <= m; i++) {
    for (j = 0; j <= r; j++) {
      dp[i][j] = inf;
    }
  }
  fnd(0, 0);
  int ans = 1e9;
  for (i = 0; i < r; i++) {
    ans = min(ans, dp[m - 1][i]);
  }
  if (ans == inf)
    ans = -1;
  else
    ans -= g;
  cout << ans;
  return 0;
}
