#include <bits/stdc++.h>
#define test(x) cout << #x <<" = " << x << endl
#define int long long
#define vint vector<int>
#define endl "\n"
using namespace std;
const int N = 2e5 + 5;
int a[N];
int n, k, m, c, d;
int Cal(int x) {
vint b(n + 2);
for (int i = 1; i <= n; ++i) {
if (a[i] >= x)
b[1]++;
else if (a[i] + min(i-1, m-1) * d + c >= x) {
b[max(1ll, i - m + 1)]++;
if (!d) {
b[i+1]--;
}
else {
int tt = (x - a[i] - c + d - 1) / d;
b[i-tt+1]--;
}
}
}
int ans = 0, t = 0;
for (int i = 1; i <= n -m + 1; ++i) {
t += b[i];
ans = max(ans, t);
}
return ans;
}
void sol(){
cin >> n >> k >> m >> c >> d;
// vint a(n + 1);
for (int i = 1; i <= n; ++i)
cin >> a[i];
int l = 0, r = 1e18, mid;
while (l < r) {
int mid = (l + r + 1) >> 1;
if (Cal(mid) >= k) l = mid;
else r = mid - 1;
}
cout << l << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
// cin >> T;
while(T--) {
sol();
}
return 0;
}
/*
*