#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i <= r; ++ i)
#define per(i, r, l) for(int i = r; i >= l; -- i)
using namespace std;
typedef long long ll;
const int N = 505;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
struct Node
{
ll s;
ll ss;
int x, y;
bool operator<(const Node &o) const { return s > o.s; }
};
ll g[N][N];
bool vis[N][N];
priority_queue<Node> pq;
int h, w, x, p, q;
void solve()
{
scanf("%d%d%d", &h, &w, &x);
scanf("%d%d", &p, &q);
rep(i, 1, h)
{
rep(j, 1, w)
{
scanf("%lld", &g[i][j]);
vis[i][j] = false;
}
}
pq.push({0, g[p][q], p, q});
vis[p][q] = true;
ll ans = g[p][q];
for (;;)
{
if (pq.empty())
break;
Node cur = pq.top();
pq.pop();
rep(d, 0, 3)
{
int nx = cur.x + dx[d], ny = cur.y + dy[d];
if (nx < 1 || nx > h || ny < 1 || ny > w || vis[nx][ny])
continue;
if (g[nx][ny] * x < cur.ss)
{
pq.push({g[nx][ny], g[nx][ny] + cur.ss, nx, ny});
vis[nx][ny] = true;
ans = max(ans, g[nx][ny] + cur.ss);
}
}
}
printf("%lld\n", ans);
}
int main()
{
solve();
return 0;
}