#include <bits/stdc++.h>
using namespace std;
const int seed = 131;
const long long LLMAX = 2e18;
const int MOD = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 1e4 + 10;
const int hmod1 = 0x48E2DCE7;
const int hmod2 = 0x60000005;
inline long long sqr(long long x) { return x * x; }
inline int sqr(int x) { return x * x; }
inline double sqr(double x) { return x * x; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long exgcd(long long a, long long b, long long &x, long long &y) {
  long long d;
  (b == 0 ? (x = 1, y = 0, d = a)
          : (d = exgcd(b, a % b, y, x), y -= a / b * x));
  return d;
}
long long qpow(long long a, long long n) {
  long long sum = 1;
  while (n) {
    if (n & 1) sum = sum * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return sum;
}
inline int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return (x > 0 ? 1 : -1);
}
deque<pair<int, int> > q;
int d[MAXN], dis[MAXN][1010];
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> d[i];
  int g, r;
  cin >> g >> r;
  sort(d, d + m);
  memset(dis, -1, sizeof(dis));
  q.push_back(pair<int, int>(0, 0));
  dis[0][0] = 0;
  while (!q.empty()) {
    pair<int, int> u = q.front();
    q.pop_front();
    if (u.first && u.second + d[u.first] - d[u.first - 1] <= g &&
        dis[u.first - 1][(u.second + d[u.first] - d[u.first - 1]) % g] == -1) {
      dis[u.first - 1][(u.second + d[u.first] - d[u.first - 1]) % g] =
          dis[u.first][u.second] +
          ((u.second + d[u.first] - d[u.first - 1]) % g == 0);
      if ((u.second + d[u.first] - d[u.first - 1]) % g)
        q.push_front(pair<int, int>(
            u.first - 1, (u.second + d[u.first] - d[u.first - 1]) % g));
      else
        q.push_back(pair<int, int>(
            u.first - 1, (u.second + d[u.first] - d[u.first - 1]) % g));
    }
    if (u.first < m - 1 && u.second + d[u.first + 1] - d[u.first] <= g &&
        dis[u.first + 1][(u.second + d[u.first + 1] - d[u.first]) % g] == -1) {
      dis[u.first + 1][(u.second + d[u.first + 1] - d[u.first]) % g] =
          dis[u.first][u.second] +
          ((u.second + d[u.first + 1] - d[u.first]) % g == 0);
      if ((u.second + d[u.first + 1] - d[u.first]) % g)
        q.push_front(pair<int, int>(
            u.first + 1, (u.second + d[u.first + 1] - d[u.first]) % g));
      else
        q.push_back(pair<int, int>(
            u.first + 1, (u.second + d[u.first + 1] - d[u.first]) % g));
    }
  }
  int ans = 0x3f3f3f3f;
  for (int i = 0; i < g; i++)
    if (dis[m - 1][i] != -1) {
      if (i == 0)
        ans = (dis[m - 1][i] - 1) * (g + r) + g;
      else
        ans = min(ans, dis[m - 1][i] * (g + r) + i);
    }
  if (ans == 0x3f3f3f3f) ans = -1;
  cout << ans << endl;
  return 0;
}
