#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5, M = 1e3 + 5;
long long n, m, node, green, red, a[N], vis[M][N], dis[M][N], ans = 4e18;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  cin >> green >> red;
  deque<pair<long long, long long>> q;
  q.push_front({0, 0});
  vis[0][0] = 1;
  sort(a, a + m);
  while (!q.empty()) {
    long long u = q.front().second;
    long long g = q.front().first;
    q.pop_front();
    if (u == m - 2) {
      if (a[m - 1] - a[u] + g <= green) {
        ans = min(ans, dis[g][u] + a[m - 1] - a[u]);
        continue;
      }
    }
    if (u + 1 < m && g + a[u + 1] - a[u] <= green &&
        !vis[(g + a[u + 1] - a[u]) % green][u + 1]) {
      vis[(g + a[u + 1] - a[u]) % green][u + 1] = 1;
      if (g + a[u + 1] - a[u] == green) {
        q.push_back({(g + a[u + 1] - a[u]) % green, u + 1});
        dis[(g + a[u + 1] - a[u]) % green][u + 1] =
            dis[g][u] + a[u + 1] - a[u] + red;
      } else {
        q.push_front({(g + a[u + 1] - a[u]) % green, u + 1});
        dis[(g + a[u + 1] - a[u]) % green][u + 1] = dis[g][u] + a[u + 1] - a[u];
      }
    }
    if (u - 1 >= 0 && g + a[u] - a[u - 1] <= green &&
        !vis[(g + a[u] - a[u - 1]) % green][u - 1]) {
      vis[(g + a[u] - a[u - 1]) % green][u - 1] = 1;
      if (g + a[u] - a[u - 1] == green) {
        q.push_back({(g + a[u] - a[u - 1]) % green, u - 1});
        dis[(g + a[u] - a[u - 1]) % green][u - 1] =
            dis[g][u] + a[u] - a[u - 1] + red;
      } else {
        q.push_front({(g + a[u] - a[u - 1]) % green, u - 1});
        dis[(g + a[u] - a[u - 1]) % green][u - 1] = dis[g][u] + a[u] - a[u - 1];
      }
    }
  }
  cout << (ans >= 2e18 ? -1 : ans) << "\n";
}
