#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string.h>
#include <string>
#include<math.h>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<queue>
#include<stack>
#include<functional>
#include<deque>
using namespace std;
#define MAXN 301000;
#define int long long
#define lll unsigned long long
#define PA pair<ll,ll>
#define INF (ll)0x3f3f3f3f*(ll)1000000
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
int n, k, m, c,d;
int a[N];
bool check(int x)
{
vector<int>cf(n + 2, 0);
for (int i = 1; i <= n; i++)
{
if (a[i] >= x)cf[1]++;
else if (a[i] + c + min(i-1,(m - 1)) * d < x);
else
{
int in;
if (d == 0)
{
in = 0;
}
else
in = ((x - a[i] - c)+(d-1)) / d;
int l = i - m + 1 >= 0 ? i - m + 1 : 1, r = i - in >= 0 ? i - in : 1;
cf[l]++, cf[r + 1]--;
}
}
for (int i = 1; i <= n; i++)
{
cf[i] = cf[i - 1] + cf[i];
if (cf[i] >= k)return true;
}
return false;
}
void solve()
{
cin >> n >> k >> m >> c >> d;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
int l = -1, r = 1e19;
while (l + 1 != r)
{
int mid = (l + r) >> 1;
if (check(mid))l = mid;
else r = mid;
}
cout << l << endl;
}
unsigned main() {
IOS;
int t = 1;// cin >> t;
while (t--) {
solve();
}
}