#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define sz(s) (int)s.size()
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
const int MOD = 1e9 + 7;
const double pi = acos(-1);
const double EPS = 1e-9;
ll binpowmod(ll a, ll b)
{
	a %= MOD;
	ll ret = 1;
	while (b)
	{
		if (b & 1)
			ret = ret * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return ret % MOD;
}
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
const int N = 1 << 18;
const int E = N * 2;
#define neigh(u,v,e) for (int e = head[u], v; ~e && ((v = to[e]), 1); e = nxt[e])
#define foreach(it, x) for(auto it = x.begin(); it != x.end(); ++it)
vector <set<pair<int,ll>>> adj;
vector<int> subtreeSz;
vector<ll> OurAns,OurAns2;
vector<int> parent;
void calcSz(int u = 0, int p = -1)
{
	subtreeSz[u] = 1;
	for (auto i = adj[u].begin(); i != adj[u].end(); ++i)
	{
		int v = i->first;
		if (v != p)
		{
			calcSz(v, u);
			subtreeSz[u] += subtreeSz[v];
			parent[v] = u;
		}
	}
}
void calcAns(int u = 0)
{
	for (auto i = adj[u].begin(); i != adj[u].end(); ++i)
	{
		int v = i->first;
		ll w = i->second;
		if (v != parent[u])
		{
			calcAns(v);
			OurAns[u] += subtreeSz[v] * w + OurAns[v];
		}
	}
}
void calcAns2(int u = 0, int cnt = 0, ll weight = 0)
{
	OurAns2[u] = (parent[u] != -1 ? OurAns2[parent[u]] : 0) + cnt * weight;
	for (auto i = adj[u].begin(); i != adj[u].end(); ++i)
	{
		int v = i->first;
		ll w = i->second;
		if (v != parent[u])
		{
			calcAns2(v, cnt + 1, w);
		}
	}
}
void solve()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<string> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	x--; y--;
	int ans = 1;
	for (int i = x + 1; i < n; ++i)
	{
		if (v[i][y] == '#')
			break;
		ans++;
	}
	for (int i = x - 1; i >= 0; --i)
	{
		if (v[i][y] == '#')
			break;
		ans++;
	}
	for (int i = y + 1; i < m; ++i)
	{
		if (v[x][i] == '#')
			break;
		ans++;
	}
	for (int i = y - 1; i >= 0; --i)
	{
		if (v[x][i] == '#')
			break;
		ans++;
	}
	cout << ans << '\n';
}
int main(void)
{
#ifdef ONLINE_JUDGE
	//freopen("hamming.in", "r", stdin);
#endif
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int tc = 1;
	//cin >> tc;
	while (tc--)
	{
		solve();
	}
}

/*/ Author : Abhishek Chauhan /*/

#include<bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace std::chrono;
using namespace __gnu_pbds;
using namespace std;

// a+b = a^b + 2*(a&b)
// whenever using a comparator return true only if a<b

#define rep(i,n)             for(int i=0;i<n;i++)
#define int                  long long
#define pb                   push_back
#define mp                   make_pair
#define all(x)               x.begin(),x.end()
#define mod                  1000000007
#define umap                 unordered_map
#define trailzero(x)         __builtin_ctz(x)
#define bpop(x)              __builtin_popcountll((x))
#define fastio               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl                 '\n'

template<class T> 
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

template<class T>
T power(T x, T y){T res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
template<class T>
T powermod(T x, T y, T p){T res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int64_t random_long(long long l,long long r){
    uniform_int_distribution<int64_t> generator(l,r);
    return generator(rng);
}
inline int64_t random_long(){
    uniform_int_distribution<int64_t> generator(LLONG_MIN,LLONG_MAX);
    return generator(rng);
}

const int mxn = 5e5+10;
int st[8*mxn];
int lazy[8*mxn];
int arr[mxn];
int merge(int a,int b){
   return min(a,b);
}
int query( int ss, int se, int qs, int qe, int si)
{
    if (qs <= ss && qe >= se)
        return st[si];
    if (se < qs || ss > qe)
        return 1e18;
    int mid = ss+(se-ss)/2;
    return merge(query( ss, mid, qs, qe, 2*si+1),query( mid+1, se, qs, qe, 2*si+2));
}
void build(int ss, int se,int si)
{
    if (ss == se){
        st[si] = arr[ss];
        return;
    }
    int mid = ss+(se-ss)/2;
    build(ss , mid, 2*si +1);
    build(mid+1, se,2*si +2);
    st[si]  = merge(st[2*si+1],st[2*si+2]);
}


void snow(){

   int n;
   cin>>n;
   rep(i,n){
    cin>>arr[i];
   }
   build(0,n-1,0);
   int ans = 0;
   for(int i=0;i<n;i++){
     int l = 0;
     int r = i-1;
     int left = i;
     while(l<=r){
       int mid = (l+r)/2;
       int f = query(0,n-1,mid,i-1,0);
       if(f<arr[i]){
         l = mid+1;
       }
       else{
         left = mid;
         r = mid-1;
       }
     }
     l = i+1;
     r = n-1;
     int right = i;
     while(l<=r){
       int mid = (l+r)/2;
       int f = query(0,n-1,i+1,mid,0);
       if(f<arr[i]){
         r = mid-1;
       }
       else{
         l = mid+1;
         right = mid;
       }
     }
     ans = max(ans,(right-left+1)*arr[i]);
   }
   cout<<ans<<endl;


}


int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    auto start = high_resolution_clock::now();
    fastio;
    int _;
    _=1;
    // cin>>_;
    for(int i=1;i<=_;i++){
     // cout<<"Case #"<<i<<": ";
        snow();
    }
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
     cerr << "Time: " << duration.count()/1000.0 << endl;
    #endif   
    return 0;
}

