#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
/*---------------------------------------------------------------------------------------------------*/ 

void solve()
{
  int n;
  cin >> n;
  int a[n];
  int ans=0;
  f(i,n)
   cin >> a[i];
 f(i,n)
 {
     int minm=mod;
     fp(j,i,n-1)
     {
         minm=min(a[j],minm);
         ans=max(ans,minm*(j-i+1));
     }

 }
 cout << ans << '\n';
    return;       
}

signed main()
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}

#pragma GCC optimize("O2")

#include <bits/stdc++.h>

namespace IN {
#define BUF_SIZE 1 << 17
static char buf[BUF_SIZE], *fs = buf, *ft = buf;
inline int nc() { return fs == ft && (ft = (fs = buf) + fread(buf, 1, BUF_SIZE, stdin), fs == ft) ? EOF : *fs++; }
template <typename T>
inline int rn(T &x) {
    x = 0;
    int f = 0;
    char ch = nc();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = 1;
        ch = nc();
        if (ch == EOF) return EOF;
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - 48;
        ch = nc();
    }
    x = f ? -x : x;
    return 0;
}
template <typename T>
inline int read(T &x) {
    return rn(x);
}
template <typename T, typename... Args>
inline int read(T &x, Args &...args) {
    rn(x);
    return read(args...);
}
#undef BUF_SIZE
}  // namespace IN

namespace OUT {
template <typename T>
inline void print(std::string, T x) {
    std::cout << x << std::endl;
}
template <typename T, typename... Args>
inline void print(std::string sep, T x, Args... args) {
    std::cout << x << sep;
    print(sep, args...);
}
}  // namespace OUT
using namespace IN;
using namespace OUT;
using namespace std;

#define INF 0x3f3f3f3f
#define LL long long
#define PLL pair<LL, LL>
#define PII pair<int, int>
#define MP make_pair
#define FI first
#define SE second
#define PB push_back
#define ALL(A) A.begin(), A.end()
#define BPQ(type, name) priority_queue<type> name
#define SPQ(type, name) priority_queue<type, vector<type>, greater<type>> name
#define REP(i, n) for (LL i = 0; i < (LL)n; ++i)
#define REP1(i, n) for (LL i = 1; i <= (LL)n; ++i)
#define REP_R(i, a, b) for (LL i = (LL)a; i < (LL)b; ++i)
#define REP_RR(i, a, b) for (LL i = (LL)a; i >= (LL)b; --i)
#define SETVAL(array, val) memset(array, val, sizeof(array))
// Debug
#define DISP(arr, n)                     \
    do {                                 \
        REP(i, n) cout << arr[i] << ' '; \
        cout << endl;                    \
    } while (0)
#define DISP1(arr, n)                     \
    do {                                  \
        REP1(i, n) cout << arr[i] << ' '; \
        cout << endl;                     \
    } while (0)
#define DISP_T(arr, n, m)                       \
    do {                                        \
        REP(i, n) {                             \
            REP(j, m) cout << arr[i][j] << ' '; \
            cout << endl;                       \
        }                                       \
    } while (0)
#define DISP_T1(arr, n, m)                       \
    do {                                         \
        REP1(i, n) {                             \
            REP1(j, m) cout << arr[i][j] << ' '; \
            cout << endl;                        \
        }                                        \
    } while (0)
#define DISP_V(vec)                                \
    do {                                           \
        for (auto elem : vec) cout << elem << ' '; \
        cout << endl;                              \
    } while (0)
#define SIZE 300010

int main() {
    LL tx, ty, ta, tb;
    cin >> tx >> ty >> ta >> tb;
    __int128 x = tx, y = ty, a = ta, b = tb;
    --y;
    LL exp = 0;
    while (x * a - x < b && x * a <= y) {
        x *= a;
        ++exp;
    }
    exp += (y - x) / b;
    cout << exp << endl;
    return 0;
}
