#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

//#define PB push_back
#define PB emplace_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

/*
bool seive[1010000];
vi prime;

void seiveGen(int limit) {
    limit += 100;
    int sqrtn = sqrt(limit);
    for(int i = 3; i <= sqrtn; i += 2) {
            if(!seive[i>>1]) {
                    for(int j = i * i; j < limit; j += i + i) {
                            seive[j>>1] = 1;
                    }
            }
    }
    prime.PB(2);
    for(int i = 3; i < limit; i += 2) {
            if(!seive[i>>1]) prime.PB(i);
    }
}
*/

//
//debug
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
//#else
//#define dbg(args...)

const int mx = 1e5 + 5;
int a[mx];

int main()
{
    optimize();
    int n;
    cin >> n;
    for( int i = 0; i < n; ++i ) cin >> a[i];
    if( n == 1 ) {
        cout << 0;
        return 0;
    }
    int b = a[0], ans = 0, extra = 0, temp = 0;
    bool ok = 0;
    for( int i = 0; i < n-1; ++i ) {
        if( a[i] > a[i+1] ) {
            temp = 0;
        }
        else {
            if( a[i+1] > b ) {
                b = a[i+1];
                temp = 0;
            }
            else {
                ++temp;
                extra = max(extra, temp);
            }
        }
    }
    if( !extra ) {
        if( a[0] < a[1] ) ans = 0;
        else ans = 1;
    }
    else ans = 1+extra;
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

//#define PB push_back
#define PB emplace_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
//#define harmonic(n) 0.57721566490153286l+log(n)

#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i);; }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
//int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
//int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

/*
bool seive[1010000];
vi prime;

void seiveGen(int limit) {
    limit += 100;
    int sqrtn = sqrt(limit);
    for(int i = 3; i <= sqrtn; i += 2) {
            if(!seive[i>>1]) {
                    for(int j = i * i; j < limit; j += i + i) {
                            seive[j>>1] = 1;
                    }
            }
    }
    prime.PB(2);
    for(int i = 3; i < limit; i += 2) {
            if(!seive[i>>1]) prime.PB(i);
    }
}
*/

//
//debug
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () {
            cerr << endl;
}

template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
//#else
//#define dbg(args...)

stack <int> st;
int death[100005];

int main()
{
    optimize();
    int n;
    cin >> n;
    int a[n];
    for( int i = 0; i < n; ++i ) cin >> a[i];
    death[0] = 0;
    st.push(0);
    for( int i = 1; i < n; ++i ) {
        int cnt = 0;
        death[i] = 1;
        while(1) {
            int t = st.top();
            //dbg(i, cnt);
            if( a[t] > a[i] ) {
                st.push(i);
                break;
            }
            else {
                death[i] = max(death[i], death[t]+1);
                st.pop();
            }
            if( st.empty() ) {
                death[i] = 0;
                st.push(i);
                break;
            }
            ++cnt;
        }
    }
    int ans = 0;
    for( int i = 0; i < n; ++i ) {
        ans = max(ans, death[i]);
    }
    cout << ans;
}


/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first

int fpow(int x,int y,int m) {
     int temp;
     if( y == 0 || x == 1)
          return 1;
     temp = fpow(x, y/2,m);
     if (y % 2 == 0)
          return ((temp)*(temp)) % m;
     else
          return (((x) % m)*((temp*temp) % m)) % m;
}
int gcd(int a,int b)
{
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n)
{
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p = 2; p*p <= n; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//*************************************************************************************************************************

int32_t main()
{     fio;

      cin>>n;
      vi life(n+2,1e15);
      stack<int> s;
      forr(i,n)
      {
            cin>>a[i];
            if(s.empty())
            {
                  s.push(i);
            }
            else if(a[s.top()]>a[i])
            {
                  life[i]=1;
                  life[i] = min(life[i],life[s.top()]<1e12?life[s.top()]:1);
                  s.push(i);
            }
            else
            {
                  life[i] = 0;
                  while(!s.empty())
                  {
                        if(a[i]>=a[s.top()])
                        {
                              life[i] = max(life[s.top()]+1,life[i]);
                              s.pop();
                        }
                        else
                        {
                              s.push(i);
                              break;
                        }
                  }
            }
      }
      mx=0;
      forr(i,n)
      {
            //cout<<life[i]<< " ";
            mx=max(life[i]<1e12?life[i]:0,mx);
      }
      cout<<mx;
}


/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first

int fpow(int x,int y,int m) {
     int temp;
     if( y == 0 || x == 1)
          return 1;
     temp = fpow(x, y/2,m);
     if (y % 2 == 0)
          return ((temp)*(temp)) % m;
     else
          return (((x) % m)*((temp*temp) % m)) % m;
}
int gcd(int a,int b)
{
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n)
{
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p = 2; p*p <= n; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//*************************************************************************************************************************

int32_t main()
{     fio;

      cin>>n;
      vi life(n+2,1e15);
      stack<int> s;
      forr(i,n)
      {
            cin>>a[i];
            if(s.empty())
            {
                  s.push(i);
            }
            else if(a[s.top()]>a[i])
            {
                  life[i] = life[s.top()]<1e15?life[s.top()]:1;
                  s.push(i);
            }
            else
            {
                  life[i] = 0;
                  while(!s.empty())
                  {
                        if(a[i]>=s.top())
                        {
                              life[i] = max(life[s.top()]+1,life[i]);
                              s.pop();
                        }
                        else
                        {
                              s.push(i);
                              break;
                        }
                  }
            }
      }
      mx=-1;
      forr(i,n)
      {
            //cout<<life[i]<< " ";
            mx=max(life[i]<1e12?life[i]:-1,mx);
      }
      cout<<mx+1;
}


/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first

int fpow(int x,int y,int m) {
     int temp;
     if( y == 0 || x == 1)
          return 1;
     temp = fpow(x, y/2,m);
     if (y % 2 == 0)
          return ((temp)*(temp)) % m;
     else
          return (((x) % m)*((temp*temp) % m)) % m;
}
int gcd(int a,int b)
{
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n)
{
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p = 2; p*p <= n; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//*************************************************************************************************************************

int32_t main()
{     fio;

      cin>>n;
      vi life(n+2,1e15);
      stack<int> s;
      forr(i,n)
      {
            cin>>a[i];
            if(s.empty())
            {
                  s.push(i);
            }
            else if(a[s.top()]>a[i])
            {
                  life[i]=1;
                  life[i] = min(life[i],life[s.top()]<1e12?life[s.top()]:0);
                  s.push(i);
            }
            else
            {
                  life[i] = 0;
                  while(!s.empty())
                  {
                        if(a[i]>=a[s.top()])
                        {
                              life[i] = max(life[s.top()]+1,life[i]);
                              s.pop();
                        }
                        else
                        {
                              s.push(i);
                              break;
                        }
                  }
            }
      }
      mx=0;
      forr(i,n)
      {
            //cout<<life[i]<< " ";
            mx=max(life[i]<1e12?life[i]:0,mx);
      }
      cout<<mx;
}


/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first

int fpow(int x,int y,int m) {
     int temp;
     if( y == 0 || x == 1)
          return 1;
     temp = fpow(x, y/2,m);
     if (y % 2 == 0)
          return ((temp)*(temp)) % m;
     else
          return (((x) % m)*((temp*temp) % m)) % m;
}
int gcd(int a,int b)
{
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n)
{
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p = 2; p*p <= n; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//*************************************************************************************************************************

int32_t main()
{     fio;

      cin>>n;
      vi life(n+2,1e15);
      stack<int> s;
      forr(i,n)
      {
            cin>>a[i];
            if(s.empty())
            {
                  s.push(i);
            }
            else if(a[s.top()]>a[i])
            {
                  life[i] = life[s.top()]<1e15?life[s.top()]:0;
                  s.push(i);
            }
            else
            {
                  life[i] = 0;
                  while(!s.empty())
                  {
                        if(a[i]>=s.top())
                        {
                              life[i] = max(life[s.top()]+1,life[i]);
                              s.pop();
                        }
                        else
                        {
                              s.push(i);
                              break;
                        }
                  }
            }
      }
      mx=-1;
      forr(i,n)
      {
            //cout<<life[i]<< " ";
            mx=max(life[i]<1e12?life[i]:-1,mx);
      }
      cout<<mx+1;
}


/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LIM 100005

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define se second
#define fi first

int fpow(int x,int y,int m) {
     int temp;
     if( y == 0 || x == 1)
          return 1;
     temp = fpow(x, y/2,m);
     if (y % 2 == 0)
          return ((temp)*(temp)) % m;
     else
          return (((x) % m)*((temp*temp) % m)) % m;
}
int gcd(int a,int b)
{
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n)
{
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p = 2; p*p <= n; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//*************************************************************************************************************************

int32_t main()
{     fio;

      cin>>n;
      vi life(n+2,1e15);
      stack<int> s;
      cin>>a[1];
      life[1] = 1e15;
      s.push(1);
      mx=0;
      for(i=2;i<=n;i++)
      {
            cin>>a[i];
            life[i] = 1;
            while(a[i]>a[s.top()])
            {
                  life[i] = max(life[i], life[s.top()]+1);
                  s.pop();
                  if(s.empty())
                        break;
            }
            s.push(i);
            if(life[i]<1e14)
            mx=max(mx,life[i]);
      }
      cout<<mx;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,ar[N];

int solve(int x){
    map<int,int> mp;
    for(int i=1;i<=x;i++) mp[ar[i]]=i;
    for(int i=1;i<=x;i++) ar[i]=N;
    int mx=0;
    for(auto ii:mp){
        int i=ii.second+1;
        while(i<=x && ar[i]!=N) ar[i++]=N;
        mx=max(mx,i-ii.second-1);
        ar[ii.second]=ii.first;
    }
    int j=0;
    for(int i=1;i<=x;i++) if(ar[i]!=N) ar[++j]=ar[i];
    if(!mx || j==x) return 0;
    return max(mx,solve(j));
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>ar[i];
    cout<<solve(n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,ar[N],ans;
vector<int> tmp,order;
int nxt[N];
bool vis[N],does;

void reduce(int x){
    vis[x]=1;
    int curr=x;
    while(curr>nxt[curr]) {
        curr=nxt[curr],does=1;
        vis[curr]=1;
    }
    nxt[x]=nxt[curr];
    if(x>nxt[x]) tmp.push_back(x);
    if(nxt[x]!=N) reduce(nxt[curr]);
}

int main(){
    cin>>n;
    ar[n+1]=N;
    for(int i=1;i<=n;i++) cin>>ar[i];
    for(int i=1;i<=n;i++) nxt[ar[i]]=ar[i+1],order.push_back(ar[i]);

    for(auto v:order) if(!vis[v]) reduce(v);
    if(!does){
        cout<<"0";
        return 0;
    }

    ans=1;
    order=tmp;
    while(order.size()){
        ans++;
        tmp.clear();
        for(auto v:order) vis[v]=0;
        for(auto v:order) if(!vis[v]) reduce(v);
        order=tmp;
    }

    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,ar[N],ans;
int nxt[N],tmp[N],order[N],t,o;
bool vis[N],does;

void reduce(int x){
    vis[x]=1;
    int curr=x;
    while(curr>nxt[curr]) {
        curr=nxt[curr],does=1;
        vis[curr]=1;
    }
    nxt[x]=nxt[curr];
    if(x>nxt[x]) tmp[t++]=x;
    if(nxt[x]!=N) reduce(nxt[curr]);
}

int main(){
    cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
    cin>>n;
    ar[n+1]=N;
    for(int i=1;i<=n;i++) cin>>ar[i];
    for(int i=1;i<=n;i++) nxt[ar[i]]=ar[i+1],order[o++]=ar[i];

    for(int i=0;i<o;i++) if(!vis[order[i]]) reduce(order[i]);
    if(!does){
        cout<<"0";
        return 0;
    }

    ans=1;
    for(int i=0;i<t;i++) order[i]=tmp[i];
    o=t;

    while(o){
        ans++;
        t=0;
        for(int i=0;i<o;i++) vis[order[i]]=0;
        for(int i=0;i<o;i++) if(!vis[order[i]]) reduce(order[i]);
        for(int i=0;i<t;i++) order[i]=tmp[i];
        o=t;
    }

    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=2e6+5;

int n,ar[N];
bool is[N];

#define lt list<int>
#define ltr list<int>::iterator

int solve(){
    lt aa;
    vector<ltr> die;

    aa.push_back(ar[0]);
    for(int i=1;i<n;i++){
        aa.push_back(ar[i]);
        auto ii= aa.end();
        ii--;
        if(ar[i-1]>ar[i]) die.push_back(ii);
    }

    int steps=0;
    while(die.size()){
        steps++;
        vector<ltr> newdie;
        for(int i=die.size()-1;i>=0;i--) {
            auto ii=die[i];
            ltr prev= ii,nxt=ii; nxt++;
            if(prev!=aa.begin() && nxt!=aa.end()) {
                prev--;
                if(*prev>*nxt && !is[*nxt]) newdie.push_back(nxt),is[*nxt]=1;
            }
            aa.erase(ii);
        }
        die.swap(newdie);
    }

    return steps;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>ar[i];
    cout<<solve();
    return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
const int N=2e6+5;
int n,x;

int main(){
    cin>>n;
    stack<pair<int,int>> st;
    int ans=0;
    while(n--){
        cin>>x;
        int redx=0;
        while(!st.empty() && st.top().f<x){
            redx=max(redx,st.top().s);
            st.pop();
        }
        if(st.size()) st.push({x,redx+1}),ans=max(ans,redx+1);
        else st.push({x,0});
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,ar[N],ans;
int nxt[N],tmp[N],order[N],t,o;
bool vis[N],does;

void reduce(int x){
    vis[x]=1;
    int curr=x;
    while(curr>nxt[curr]) {
        curr=nxt[curr],does=1;
        vis[curr]=1;
    }
    nxt[x]=nxt[curr];
    if(x>nxt[x]) tmp[t++]=x;
}

int main(){
    cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
    cin>>n;
    ar[n+1]=N;
    for(int i=1;i<=n;i++) cin>>ar[i];
    for(int i=1;i<=n;i++) nxt[ar[i]]=ar[i+1],order[o++]=ar[i];

    for(int i=0;i<o;i++) if(!vis[order[i]]) reduce(order[i]);
    if(!does){
        cout<<"0";
        return 0;
    }

    ans=1;
    for(int i=0;i<t;i++) order[i]=tmp[i];
    o=t;

    while(o){
        ans++;
        t=0;
        for(int i=0;i<o;i++) vis[order[i]]=0;
        for(int i=0;i<o;i++) if(!vis[order[i]]) reduce(order[i]);
        for(int i=0;i<t;i++) order[i]=tmp[i];
        o=t;
    }

    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,ar[N];

int solve(int x){
    int j=1,i=2;
    while(i<=x){
        if(ar[i-1]<ar[i]) ar[++j]=ar[i];
        i++;
    }
    if(i==j+1) return 0;
    return 1+ solve(j);
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>ar[i];
    cout<<solve(n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,ar[N],ans;
vector<int> tmp,order;
int nxt[N];
bool vis[N];

bool does;
void reduce(int x){
    vis[x]=1;
    int curr=x;
    while(curr>nxt[curr]) curr=nxt[curr],does=1;
    nxt[x]=nxt[curr];
    if(x>nxt[x]) tmp.push_back(x);
    if(nxt[x]!=N) reduce(nxt[curr]);
}

int main(){
    cin>>n;
    ar[n+1]=N;
    for(int i=1;i<=n;i++) cin>>ar[i];
    for(int i=1;i<=n;i++) nxt[ar[i]]=ar[i+1],order.push_back(ar[i]);

    while(1){
        for(auto v:order) vis[v]=0;
        does=0;
        for(auto v:order) if(!vis[v]) reduce(v);
        if(!does) break;
        ans++;
        order=tmp;
        tmp.clear();
    }

    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,ar[N];

int solve(int x){
    map<int,int> mp;
    for(int i=1;i<=x;i++) mp[ar[i]]=i;
    for(int i=1;i<=x;i++) ar[i]=N;
    int mx=0;
    for(auto ii:mp){
        int i=ii.second+1;
        while(i<=x && ar[i]!=N) ar[i++]=N;
        mx=max(mx,i-ii.second-1);
        ar[ii.second]=ii.first;
    }
    int j=0;
    for(int i=1;i<=x;i++) if(ar[i]!=N) ar[++j]=ar[i];
    if(!mx || j==x) return 0;
    // for(int i=1;i<=j;i++) cerr<<ar[i]<<" ";cerr<<"\n";
    return 1+max(mx-1,solve(j));
}

int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>ar[i];
    cout<<solve(n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std ;
int main()
{

    int n ;
    cin>>n ;
   int a[n] ;
    for(int i=0 ; i<n ; i++)
    {

        cin>>a[i];
    }
    int sz = n ;
    int steps = 0 ;
    while(1)
    {

    int last = 0 ;
    for(int i=0 ; i<sz ; i++)
    {
           // cout<<a[i]<<" "<<a[i+1]<<endl ;
           if(i+1 < sz)
        if(a[i] > a[i+1])
            continue;
        else
        {
            a[last+1] = a[i] ;
            last++ ;

        }
       // cout<<last<<endl ;
    }
  //  cout<<last<<" "<<sz<<endl ;
    if(last+1==sz)
        break ;
    else
    {

        steps++;
        sz = last+1  ;
    }

    }
    cout<<steps<<endl ;
}


#include<bits/stdc++.h>
using namespace std ;
#define p1 pair<int, int>
int A[100000+10] ;
int tree[4*100000 + 50] ;
void update(int node, int start, int end, int idx, int val)
{
    if(start == end)
    {
        // Leaf node
        A[idx] += val;
        tree[node] += val;
    }
    else
    {
        int mid = (start + end) / 2;
        if(start <= idx and idx <= mid)
        {
            // If idx is in the left child, recurse on the left child
            update(2*node, start, mid, idx, val);
        }
        else
        {
            // if idx is in the right child, recurse on the right child
            update(2*node+1, mid+1, end, idx, val);
        }
        // Internal node will have the sum of both of its children
        tree[node] = max(tree[2*node]  ,  tree[2*node+1]);
    }
}
int query(int node, int start, int end, int l, int r)
{
    if(r < start or end < l)
    {
        // range represented by a node is completely outside the given range
        return 0;
    }
    if(l <= start and end <= r)
    {
        // range represented by a node is completely inside the given range
        return tree[node];
    }
    // range represented by a node is partially inside and partially outside the given range
    int mid = (start + end) / 2;
    int pa = query(2*node, start, mid, l, r);
    int p2 = query(2*node+1, mid+1, end, l, r);
    return max(pa , p2) ;
}
int main()
{

    int n ;
    cin>>n ;
    int a[n+1] ;
    for(int i =1; i<=n ;i++)
        cin>>a[i] ;
    stack<p1> s ;
    int closet[n+1] ;
      memset(closet , -1 , sizeof(closet)) ;
      s.push({a[1] , 1}) ;
      for(int i=2 ; i<=n ; i++)
      {
          while(!s.empty() && a[i] > s.top().first)
          {
              s.pop();
          }
          if(!s.empty())
          closet[a[i]] = s.top().second;
          s.push({a[i], i}) ;
      }
      int myans = 0 ;
      for(int i=2 ; i<=n ; i++)
      {

          if(a[i] < a[i-1])
            A[i] = 1 ;
            else
            {

                int x = closet[a[i]] ;
                //co//ut<<ans<<endl ;
                //cout<<x<<endl ;
                if(x==-1)
                    A[i] = 0 ;
                else
                  A[i] =   query(1 , 1 , n, x+1, i-1) +1 ;

            }
            myans = max(myans , A[i]) ;
            update(1 , 1 , n, i, A[i]);

      }
      cout<<myans<<endl ;
}


#include<bits/stdc++.h>
using namespace std ;
int main()
{

    int n ;
    cin>>n ;
   int a[n] ;
    for(int i=0 ; i<n ; i++)
    {

        cin>>a[i];
    }
    int sz = n ;
    int steps = 0 ;
    while(1)
    {

    int last = 0 ;
    for(int i=0 ; i<sz ; i++)
    {
           // cout<<a[i]<<" "<<a[i+1]<<endl ;
           if(i+1 < sz)
           {

        if(a[i] > a[i+1])
            continue;
        else
        {
            a[last+1] = a[i+1] ;
            last++ ;

        }
       // cout<<last<<endl ;
           }
    }
    //for(int i=0 ; i<=last; i++)
    //    cout<<a[i]<<" " ;
   // cout<<endl ;
    //cout<<last<<" "<<sz<<endl ;
    if(last+1==sz)
        break ;
    else
    {

        steps++;
        sz = last+1  ;
    }

    }
    cout<<steps<<endl ;
}


#include<bits/stdc++.h>
using namespace std ;
#define p1 pair<int, int>
int main()
{

    int n ;
    cin>>n ;
    int a[n+1] ;
    for(int i =1; i<=n ;i++)
        cin>>a[i] ;
    stack<p1> s ;
    int closet[n+1] ;
      memset(closet , -1 , sizeof(closet)) ;
      s.push({a[1] , 1}) ;
      for(int i=2 ; i<=n ; i++)
      {
          while(!s.empty() && a[i] > s.top().first)
          {
              s.pop();
          }
          if(!s.empty())
          closet[a[i]] = s.top().second;
          s.push({a[i], i}) ;
      }
      int ans = 0 ;
      for(int i=2 ; i<=n ; i++)
      {

          int x = closet[a[i]] ;
          if(x==-1)
            continue ;

          ans +=(i-x)-1 ;

      }
      cout<<ans<<endl ;
}


#include<bits/stdc++.h>
using namespace std ;
#define p1 pair<int, int>
int A[10010] ;
int tree[4*10010] ;
void update(int node, int start, int end, int idx, int val)
{
    if(start == end)
    {
        // Leaf node
        A[idx] += val;
        tree[node] += val;
    }
    else
    {
        int mid = (start + end) / 2;
        if(start <= idx and idx <= mid)
        {
            // If idx is in the left child, recurse on the left child
            update(2*node, start, mid, idx, val);
        }
        else
        {
            // if idx is in the right child, recurse on the right child
            update(2*node+1, mid+1, end, idx, val);
        }
        // Internal node will have the sum of both of its children
        tree[node] = max(tree[2*node]  ,  tree[2*node+1]);
    }
}
int query(int node, int start, int end, int l, int r)
{
    if(r < start or end < l)
    {
        // range represented by a node is completely outside the given range
        return 0;
    }
    if(l <= start and end <= r)
    {
        // range represented by a node is completely inside the given range
        return tree[node];
    }
    // range represented by a node is partially inside and partially outside the given range
    int mid = (start + end) / 2;
    int pa = query(2*node, start, mid, l, r);
    int p2 = query(2*node+1, mid+1, end, l, r);
    return max(pa , p2) ;
}
int main()
{

    int n ;
    cin>>n ;
    int a[n+1] ;
    for(int i =1; i<=n ;i++)
        cin>>a[i] ;
    stack<p1> s ;
    int closet[n+1] ;
      memset(closet , -1 , sizeof(closet)) ;
      s.push({a[1] , 1}) ;
      for(int i=2 ; i<=n ; i++)
      {
          while(!s.empty() && a[i] > s.top().first)
          {
              s.pop();
          }
          if(!s.empty())
          closet[a[i]] = s.top().second;
          s.push({a[i], i}) ;
      }
      int myans = 0 ;
      for(int i=2 ; i<=n ; i++)
      {

          if(a[i] < a[i-1])
            A[i] = 1 ;
            else
            {

                int x = closet[a[i]] ;
                //co//ut<<ans<<endl ;
                //cout<<x<<endl ;
                if(x==-1)
                    A[i] = 0 ;
                else
                  A[i] =   query(1 , 1 , n, x+1, i-1) +1 ;

            }
            myans = max(myans , A[i]) ;
            update(1 , 1 , n, i, A[i]);

      }
      cout<<myans<<endl ;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0; i<n; ++i)
        cin>>p[i];
    stack<int> s;
    vector<int> td(n, 0);
    int ans = 0;
    td[0] = 0;
    s.push(0);
    for(int i=1; i<n; ++i) {
        if(p[i] < p[i-1]) {
            td[i] = 1;
        }
        else {
            td[i] = 1;
            if(p[i] < p[s.top()])
                ++td[i];
            while(!s.empty() && p[i] > p[s.top()]) {
                td[i] += td[s.top()];
                s.pop();
            }
            if(s.empty())
                td[i] = 0;
            s.push(i);
        }
        ans = max(ans, td[i]);
        // cout<<td[i]<<" ";
    }
    // cout<<endl;
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0; i<n; ++i)
        cin>>p[i];
    ++n;
    p.pb(2 * 1e5);
    int prev = p[0];
    int ans = 0;
    int count = 0;
    for(int i=1; i<n; ++i) {
        if(p[i] > prev) {
            // ++count;
            prev = p[i];
            ans = max(ans, count);
            count = 0;
        }
        else if(p[i] > p[i-1]){
            ++count;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0; i<n; ++i)
        cin>>p[i];
    stack<int> s;
    vector<int> td(n, 0);
    int ans = 0;
    td[0] = 0;
    s.push(0);
    for(int i=1; i<n; ++i) {
        if(p[i] < p[i-1]) {
            td[i] = 1;
        }
        else {
            td[i] = 1;
            int temp = 1;
            while(!s.empty() && p[i] > p[s.top()]) {
                temp = max(temp, td[s.top()]);
                s.pop();
            }
            td[i] += temp;
            if(s.empty())
                td[i] = 0;
            s.push(i);
        }
        ans = max(ans, td[i]);
        // cout<<td[i]<<" ";
    }
    // cout<<endl;
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0; i<n; ++i)
        cin>>p[i];
    ++n;
    p.pb(2 * 1e5);
    int prev = p[0];
    int ans = 0;
    int count = 0;
    stack<int> s;
    for(int i=1; i<n; ++i) {
        if(p[i] > prev) {
            prev = p[i];
            if(!s.empty())
                ans = max(ans, count + 1);
            count = 0;
            while(!s.empty())
                s.pop();
        }
        else{
            if(s.empty() || p[i] < s.top()) {
                s.push(p[i]);
            }
            else {
                int temp = 0;
                while(!s.empty() && p[i] > s.top()) {
                    ++temp;
                    s.pop();
                }
                s.push(p[i]);
                count = max(count, temp);
            }
        }
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 210000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
#define present(container, element) (container.find(element) != container.end())
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}

int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(n);
    cin>>a;
    vl x;
    REP(0,n-1){
        lo push=a[i];
        while(a[i]>a[i+1] and i<n-1){
            i++;
        }
        x.pb(push);
    }
    if(x.size()==a.size()){
        cout<<"0";
        return 0;
    }
    a.clear();
    REP(0,x.size()-1){
        lo push = x[i];
        while(x[i]>x[i+1] and i<x.size()-1){
            i++;
        }
    }
    if(x.size()==a.size())cout<<"1";
    else cout<<2;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 210000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
#define present(container, element) (container.find(element) != container.end())
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}

int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(n);
    cin>>a;
    vl x;
    REP(0,n-1){
        lo push=a[i];
        while(a[i]>a[i+1] and i<n-1){
            i++;
        }
        x.pb(push);
    }
    if(n>1){
        if(a[n-1]>a[n-2])x.pb(a[n-1]);
    }
    else x.pb(a[0]);
    if(x.size()==a.size()){
        cout<<"0";
        return 0;
    }
    a.clear();
    REP(0,x.size()-1){
        lo push = x[i];
        while(x[i]>x[i+1] and i<x.size()-1){
            i++;
        }
        a.pb(push);
    }
    n=x.size();
    if(n>1){
        if(a[n-1]>a[n-2])a.pb(x[n-1]);
    }
    else a.pb(x[0])
    if(x.size()==a.size())cout<<"1";
    else cout<<2;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 210000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
#define present(container, element) (container.find(element) != container.end())
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}

int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(n);
    cin>>a;
    vl x;
    REP(0,n-1){
        lo push=a[i];
        while(a[i]>a[i+1] and i<n-1){
            i++;
        }
        x.pb(push);
    }
    if(n>1)if(a[n-1]>a[n-2])x.pb(a[n-1]);
    if(x.size()==a.size()){
        cout<<"0";
        return 0;
    }
    a.clear();
    REP(0,x.size()-1){
        lo push = x[i];
        while(x[i]>x[i+1] and i<x.size()-1){
            i++;
        }
    }
    lo n=x.size();
    if(n>1)if(a[n-1]>a[n-2])x.pb(a[n-1]);
    if(x.size()==a.size())cout<<"1";
    else cout<<2;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 210000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
#define present(container, element) (container.find(element) != container.end())
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}

int main(){
    std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(n),t_death(n);
    cin>>a;
    t_death[0]=-1;
    vl s(1,0);
    lo sol=0;
    REP(1,n){
        t_death[i]=0;
        while(s.size()>0 and a[s.back()]<a[i]){
            t_death[i]=max(t_death[i],t_death[s.back()]+1);
            s.pop_back();
        }
        if(s.empty())t_death[i]=-1;

        s.pb(i);
        sol=max(sol,t_death[i]+1);
    }
    cout<<sol;
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define multitest int t; cin >> t; while(t--) solve();
using namespace std;
// ull bigMod(ull b, ull p, ull m) {b=b%m;if(p==0) return 1;else if(p%2==0) return ((ull) pow(bigMod(b, p/2, m), 2))%m;else return ((ull) pow(bigMod(b, (p-1)/2, m), 2)*b)%m;}
// ull nCr(ull n, ull r) {ull ans=1;if(r>=n-r) {for(ull i=r+1;i<=n;i++) {ans=ans*i;}for(ull i=1;i<=n-r;i++) {ans=ans/i;}}else {for(ull i=n-r+1;i<=n;i++) {ans=ans*i;}for(ull i=1;i<=r;i++) { ans=ans/i;}}return ans;}
// ull fib(ull a) {const long double root5=sqrt(5);const long double root5plus1div2=(root5+1)/2;return round(pow(root5plus1div2, a)/root5);}
// bool isPrime(ull a) {if(a%2==0) return false;for(int i=3; i<=sqrt(a); i+=2) {if(a%i==0) return false;}return true;}
// bool coPrime(ull a, ull b) {if(gcd(a, b)==1) return true;else return false;}
// ld toRadian(ld deg) {return (deg*pi/180);}
// ull strToInt(string a) {int len=a.length();int power=0;ull tot=0;for(int i=len-1; i>=0; i--) {tot=tot+pow(10, power)*(a[i]-'0');power++;}return tot;}
// bool desc(int a, int b) {return a>b;}
// ull mex(int* arr, int n) {sort(arr, arr+n);int now=-1;for(int i=0; i<n; i++) {if(arr[i]==now+1) {now++;}else if(arr[i]==now) {}else {return now+1;}}return now+1;}
// ld slope(ld xdiff, ld ydiff) {return (ydiff/xdiff);}
// bool binSearch(ll* arr, ll n, ll target) {ull l=0, r=n-1;while(l<r) {int mid=(l+r)/2;if(arr[mid]>=target) {r=mid;}else {l=mid+1;}}if(arr[l]==target) {return true;}else {return false;}}
// int ascii(char x) {return int(x);}
// ld sine(ld x) {return sin(toRadian(x));}
// ld cosine(ld x) {return cos(toRadian(x));}
// ld tangent(ld x) {return tan(toRadian(x));}
// ull hammDist(string a, string b, ull len) {ull cnt=0;for(int i=0; i<len; i++) {if(a[i]!=b[i]) cnt++;}return cnt;}
// ull binStrToInt(string a, ull len) {ull num=0;for(int i=len-1; i>=0; i--) {if(a[i]=='1') {num=num+pow((ull) 2, len-i-1);}}return num;}

void solve() {
    int n, t;
    cin >> n >> t;
    int arr[n], tot=0;
    for(int i=0; i<n; i++) cin >> arr[i];
    for(int i=0; i<n; i++) {
        tot+=((arr[i]/t)*t);
    }
    cout << tot << endl;
}

int main() {
    cin.tie(NULL);
    cout.tie(NULL);
    ios::sync_with_stdio(false);
    solve();
    // multitest
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define multitest int t; cin >> t; while(t--) solve();
using namespace std;
// ull bigMod(ull b, ull p, ull m) {b=b%m;if(p==0) return 1;else if(p%2==0) return ((ull) pow(bigMod(b, p/2, m), 2))%m;else return ((ull) pow(bigMod(b, (p-1)/2, m), 2)*b)%m;}
// ull nCr(ull n, ull r) {ull ans=1;if(r>=n-r) {for(ull i=r+1;i<=n;i++) {ans=ans*i;}for(ull i=1;i<=n-r;i++) {ans=ans/i;}}else {for(ull i=n-r+1;i<=n;i++) {ans=ans*i;}for(ull i=1;i<=r;i++) { ans=ans/i;}}return ans;}
// ull fib(ull a) {const long double root5=sqrt(5);const long double root5plus1div2=(root5+1)/2;return round(pow(root5plus1div2, a)/root5);}
// bool isPrime(ull a) {if(a%2==0) return false;for(int i=3; i<=sqrt(a); i+=2) {if(a%i==0) return false;}return true;}
// bool coPrime(ull a, ull b) {if(gcd(a, b)==1) return true;else return false;}
// ld toRadian(ld deg) {return (deg*pi/180);}
// ull strToInt(string a) {int len=a.length();int power=0;ull tot=0;for(int i=len-1; i>=0; i--) {tot=tot+pow(10, power)*(a[i]-'0');power++;}return tot;}
// bool desc(int a, int b) {return a>b;}
// ull mex(int* arr, int n) {sort(arr, arr+n);int now=-1;for(int i=0; i<n; i++) {if(arr[i]==now+1) {now++;}else if(arr[i]==now) {}else {return now+1;}}return now+1;}
// ld slope(ld xdiff, ld ydiff) {return (ydiff/xdiff);}
// bool binSearch(ll* arr, ll n, ll target) {ull l=0, r=n-1;while(l<r) {int mid=(l+r)/2;if(arr[mid]>=target) {r=mid;}else {l=mid+1;}}if(arr[l]==target) {return true;}else {return false;}}
// int ascii(char x) {return int(x);}
// ld sine(ld x) {return sin(toRadian(x));}
// ld cosine(ld x) {return cos(toRadian(x));}
// ld tangent(ld x) {return tan(toRadian(x));}
// ull hammDist(string a, string b, ull len) {ull cnt=0;for(int i=0; i<len; i++) {if(a[i]!=b[i]) cnt++;}return cnt;}
// ull binStrToInt(string a, ull len) {ull num=0;for(int i=len-1; i>=0; i--) {if(a[i]=='1') {num=num+pow((ull) 2, len-i-1);}}return num;}

void solve() {
    int n, stot;
    cin >> n >> stot;
    int arr[n], tot=0, max=0;
    for(int i=0; i<n; i++) cin >> arr[i];
    for(int t=stot; t<=100; t++) {
        tot=0;
    for(int i=0; i<n; i++) {
        tot+=((arr[i]/t)*t);
    }
    if(max<tot) max=tot;
    }
    cout << max << endl;
}

int main() {
    cin.tie(NULL);
    cout.tie(NULL);
    ios::sync_with_stdio(false);
    solve();
    // multitest
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[101],l,i,j;
	cin>>n>>l;
	int ans=0;
	int x=0;
	int min=9999999;
	for(i=0;i<n;i++){
		scanf("%d",&j);
		if(j>=l)
		{
			if(min<=j)
			min=j;
			ans+=j/l;
			x++;
		}
	}
	cout<<ans*l<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int n,l,a[10001],ans,maxn=-1;
int main()
{
    cin>>n>>l;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=l;i<=101;i++)
    {
        ans=0;
        for(int j=1;j<=n;j++) ans+=a[j]/i;
        if(ans*i>maxn) maxn=ans*i;
    }
    cout<<maxn;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[101],l,i,j;
	cin>>n>>l;
	int ans=0;
	for(i=0;i<n;i++){
		scanf("%d",&j);
		if(j>=l)
		{
			ans+=j/l;
		}
	}
	cout<<ans*l<<endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
ll n, l, a[107];

int main() {
    cin >> n >> l;

    ll maxn = 0;
    for(ll i = 0; i < n; ++i) {
        cin >> a[i];
        maxn = max(a[i], maxn);
    }

    ll ans = 0;
    for(ll i = l; i <= maxn; ++i) {
        ll res = 0;
        for(ll j = 0; j < n; ++j) res += a[j]/i;

        ans = max(ans, res * i);
    }

    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
ll n, l, a[107];

int main() {
    cin >> n >> l;

    ll maxn = 0;
    for(ll i = 0; i < n; ++i) {
        cin >> a[i];
        maxn = max(a[i], maxn);
    }

    ll ans = 0;
    for(ll i = l; i <= maxn; ++i) {
        ll res = 0;
        for(ll j = 0; j < n; ++j) res += a[j]/i;

        ans = max(ans, res * l);
    }

    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
void in(int &n)
{
	n=0;int f=1;char c=getchar();
	while (c<'0'||'9'<c){if (c=='-')f*=-1;c=getchar();}
	while ('0'<=c&&c<='9'){n=n*10+(c-'0');c=getchar();}
	n*=f;
}
int a[105];
int main()
{
    int n,m;
    in(n);in(m);
    for (int i=0;i<n;i++)
    	in(a[i]);
    int ans=0;
    for (int i=m;i<=100;i++)
    {
    	int s=0;
    	for (int j=0;j<n;j++)
    		s+=a[j]/i;
    	ans=max(ans,i*s);
    }
    printf ("%d",ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdint>
#include <vector>

int main(){
  int n = 0;
  std::cin >> n;
  int l = 0;
  std::cin >> l;
  std::vector<int32_t> e;
  for (int i = 0; i < n; i++){
    int32_t di;
    std::cin >> di;
    e.push_back(di);
  }
  int32_t max = 0;
  for(int i = 0; i < n; i++){
    if (e[i] > max){
      max = e[i];
    }
  }
  int32_t min = max >= l ? max : l;
  for(int i = 0; i < n; i++){
    if (e[i] < min && e[i] >= l){
      min = e[i];
    }
  }
  int32_t sum = 0;
  for (int i = 0; i < n; ++i)
  {
    sum += (int32_t)(e[i] / min) ;
  }
  std::cout << sum * min;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdint>
#include <vector>

int32_t nod(int32_t a, int32_t b){
  for (int i = a; i > 0; i--) {
      if (a % i == 0 && b % i == 0) {
          return i;
          break;
      }
  }
}

int main(){
  int n = 0;
  std::cin >> n;
  int l = 0;
  std::cin >> l;
  std::vector<int32_t> e;
  for (int i = 0; i < n; i++){
    int32_t di;
    std::cin >> di;
    e.push_back(di);
  }
  int32_t nownod = e[0];
  for(int i = 1; i < n; i++){
    nownod = nod(nownod, e[i]);
  }
  if (nownod < l){
    nownod = l;
  }
  int32_t sum = 0;
  for (int i = 0; i < n; ++i)
  {
    sum += (int32_t)(e[i] / nownod);
  }
  std::cout << sum * nownod;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdint>
#include <vector>

int32_t nod(int32_t a, int32_t b){
  for (int i = a; i > 0; i--) {
      if (a % i == 0 && b % i == 0) {
          return i;
          break;
      }
  }
}

int main(){
  int n = 0;
  std::cin >> n;
  int l = 0;
  std::cin >> l;
  std::vector<int32_t> e;
  for (int i = 0; i < n; i++){
    int32_t di;
    std::cin >> di;
    e.push_back(di);
  }
  int32_t max = 0;
  for(int i = 0; i < n; i++){
    if (max < e[i]){
      max = e[i];
    }
  }
  int32_t maxsum = 0;
  for (int32_t step = l; step <= max; step++){
    int32_t sum = 0;
    for (int i = 0; i < n; ++i)
    {
      sum += (int32_t)(e[i] / step);
    }
    if (sum * step > maxsum){
      maxsum = sum * step;
    }
  }
  std::cout << maxsum;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdint>
#include <vector>

int main(){
  int n = 0;
  std::cin >> n;
  int l = 0;
  std::cin >> l;
  std::vector<int32_t> e;
  for (int i = 0; i < n; i++){
    int32_t di;
    std::cin >> di;
    e.push_back(di);
  }
  int32_t sum = 0;
  for (int i = 0; i < n; ++i)
  {
    sum += (int32_t)(e[i] / l) ;
  }
  std::cout << sum * l;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdint>
#include <vector>

int32_t nod(int32_t a, int32_t b){
  for (int i = a; i > 0; i--) {
      if (a % i == 0 && b % i == 0) {
          return i;
          break;
      }
  }
}

int main(){
  int n = 0;
  std::cin >> n;
  int l = 0;
  std::cin >> l;
  std::vector<int32_t> e;
  for (int i = 0; i < n; i++){
    int32_t di;
    std::cin >> di;
    e.push_back(di);
  }
  int32_t nownod = e[0];
  for(int i = 1; i < n; i++){
    nownod = nod(nownod, e[i]);
  }
  int32_t sum = 0, suml = 0;
  for (int i = 0; i < n; ++i)
  {
    sum += (int32_t)(e[i] / nownod);
    suml += (int32_t)(e[i] / l);
  }
  std::cout << sum << " " << suml << std::endl;
  std::cout << nownod << " " << l << std::endl;
  std::cout << ((sum * nownod >= suml * nownod) ? (sum * nownod) : (suml * l));
  return 0;
}


// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int a[101],n,l;
int main(){
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int maxv=0;
	for(int i=l;i<=100;i++){
		int ans=0;
		for(int j=1;j<=n;j++){
			ans+=a[j]/i;
		}
		if(ans*i>maxv){
			maxv=ans*i;
		}
	}
	cout<<maxv<<endl;
	//return 233;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,k,ans=0,maxn=-1,a[10002];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=k;i<=100;i++)
    {
        ans=0;
        for(int j=1;j<=n;j++)
            ans+=a[j]/i;
        maxn=max(maxn,ans*i);
    }
    cout<<maxn<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0;
void dfs(int nm,int f,int sum)
{
	if(nm>cnt) return ;
	ans=max(ans,sum);
	if(a[nm]>=f) dfs(nm+1,f,sum+f);
	dfs(nm+1,a[nm],a[nm]);
}
int main()
{
  //  freopen("window.in","r",stdin);
    //freopen("window.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	int x;
        cin>>x;
		if(x>=m) a[++cnt]=x;
	}
    sort(a+1,a+1+cnt);
    dfs(1,a[1],a[1]);
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0,sum=0;
int main()
{
//	freopen("window.in","r",stdin);
// 	freopen("window.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
	}
	for(int i=m;i<=100;i++)
    {
    	sum=0;
    	for(int j=1;j<=n;j++)
    		sum=sum+(a[j]/i);
    	ans=max(ans,sum*i);
    }
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0,sum=0;
int main()
{
//	freopen("window.in","r",stdin);
// 	freopen("window.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cout<<a[i]<<"\n";
	}
	for(int i=m;i<=100;i++)
    {
    	sum=0;
    	for(int j=1;j<=n;j++)
    		sum=sum+(a[j]/i);
    	ans=max(ans,sum*i);
    }
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0,sum=0;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	int x;
        cin>>x;
		if(x>=m) a[++cnt]=x;
	}
	for(int i=m;i<=100;i++)
    {
    	sum=0;
    	for(int j=1;j<=cnt;j++)
    		sum=sum+a[j]/i;
    	ans=max(ans,sum*i);
    }
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0;
void dfs(int nm,int f,int sum)
{
	ans=max(ans,sum);
	if(nm==cnt+1) return ;
	if(a[nm]>=f)
	{
		int k=a[nm]/f;
		dfs(nm+1,f,sum+f*k);
	}
	dfs(nm+1,a[nm],a[nm]);
}
int main()
{
  //freopen("window.in","r",stdin);
 // freopen("window.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	int x;
        cin>>x;
		if(x>=m) a[++cnt]=x;
	}
    sort(a+1,a+1+cnt);
    dfs(2,a[1],a[1]);
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0;
void dfs(int nm,int f,int sum)
{

	ans=max(ans,sum);
	if(nm==cnt+1) return ;
	if(a[nm]>=f)
	{
		int k=a[nm]/f;
		dfs(nm+1,f,sum+f*k);
	}
	dfs(nm+1,a[nm],a[nm]);
}
int main()
{
//  	freopen("window.in","r",stdin);
// 	freopen("window.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	int x;
        cin>>x;
		if(x>=m) a[++cnt]=x;
	}
	if(cnt==0) {
		cout<<0;
		return 0;
	}
    sort(a+1,a+1+cnt);
    dfs(2,a[1],a[1]);
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0,sum=0;
int main()
{
//	freopen("window.in","r",stdin);
// 	freopen("window.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
	}
	for(int i=m;i<=100;i++)
    {
    	sum=0;
    	for(int j=1;j<=n;j++)
    		sum=sum+a[j]/i;
    	ans=max(ans,sum*i);
    }
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0;
int main()
{
//  freopen("window.in","r",stdin);
// 	freopen("window.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	int x;
        cin>>x;
		if(x>=m) a[++cnt]=x;
	}
	for(int i=m;i<=100;i++)
    {
    	sum=0;
    	for(int j=1;j<=cnt;j++)
    		sum=sum+a[j]/i;
    	ans=max(ans,sum*i);
    }
	cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=10010;
int a[N];
int n,m,cnt=0,ans=0;
void dfs(int nm,int f,int sum)
{
	ans=max(ans,sum);
	if(nm>cnt) return ;
	if(a[nm]>=f) dfs(nm+1,f,sum+f);
	dfs(nm+1,a[nm],a[nm]);
}
int main()
{

    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	int x;
        cin>>x;
		if(x>=m) a[++cnt]=x;
	}
    sort(a+1,a+1+cnt);
    dfs(1,a[1],a[1]);
	cout<<ans;
    return 0;
}


#include <cstdio>
#include <algorithm>
#define rr register int
using namespace std;
inline int read()
{
    char ch=getchar();
    if(!(~ch))return 0;
    int f=1;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    int x=0;
    while(ch>='0'&&ch<='9')
    {
        x=(x<<3)+(x<<1)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int f[100];
int main()
{
    int n=read(),m=read(),maxn=0;
    for(rr i=0;i<n;++i)//读入
    {
        f[i]=read();
        if(f[i]>maxn)maxn=f[i];
    }
    int ans=0;
    for(rr i=m;i<=maxn;++i)//枚举横条长度
    {
        rr sum=0;//计可以割出几条横条
        for(rr j=0;j<n;++j)
            sum+=f[j]/i;
        sum*=i;
        if(sum>ans)ans=sum;//若现在百叶窗面积更大，就更新
    }
    printf("%d\n",ans);
    return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <string>
#include <set>
#include <stack>

#define MOD 1000000007
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
int a[110],ma;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(false);
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=l;i<=100;i++){
		int res=0;
		for(int j=0;j<n;j++)
			res+=a[j]/i;
		ma=max(res,ma);
	}
	cout<<ma<<endl;
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <string>
#include <set>
#include <stack>

#define MOD 1000000007
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
int a[110],ma;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(false);
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=l;i<=100;i++){
		int res=0;
		for(int j=0;j<n;j++)
			res+=a[j]/i;
		ma=max(res*i,ma);
	}
	cout<<ma<<endl;
	return 0;
}


/* Author haleyk10198 */
/* �@��:  haleyk10198 */
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <string>
#include <set>
#include <stack>

#define MOD 1000000007
#define INF 2147483647
#define PI 3.1415926535897932384626433
#define ll long long
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))

using namespace std;
int a[110],ma;

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(false);
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++){
		if(a[i]<l)
			continue;
		int res=0;
		for(int j=0;j<n;j++)
			res+=a[j]/a[i];
		ma=max(ma,res*a[i]);
	}
	cout<<ma<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,l;
int a[105];
int main() {
    cin>>n>>l;
    int temp;
    int cnt=0;
    for(int i=1; i<=n; i++) {
        cin>>temp;
        if(temp>=l) a[++cnt] = temp;
    }
    if(cnt==0) {
        cout<<0;
        return 0;
    }
    sort(a+1,a+1+cnt);
    int pos;
    int squ=0,h=0,w=0;
    for(int i=1; i<=cnt; i++) {
        w = a[i];
        h=0;
        for(int j=i; j<=n; j++) {
            h+=a[j]/w;
        }
        squ = max(squ,w*h);
    }
    cout<<squ;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,l;
int a[105];
int main() {
    cin>>n>>l;
    int temp;
    int cnt=0;
    for(int i=1; i<=n; i++) {
        cin>>temp;
        if(temp>=l) a[++cnt] = temp;
    }
    if(cnt==0) {
        cout<<0;
        return 0;
    }
    sort(a+1,a+1+cnt);
    int pos;
    int squ=0,h=0,w=0;
    for(int i=1; i<=cnt; i++) {
        w = a[i];
        h=0;
        for(int j=i; j<=cnt; j++) {
            h+=a[j]/w;
        }
        squ = max(squ,w*h);
    }
    cout<<squ;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,l;
int a[105];
int main() {
    cin>>n>>l;
    int temp;
    int cnt=0;
    for(int i=1; i<=n; i++) {
        cin>>a[i];
    }
    sort(a+1,a+1+cnt);
    int pos;
    int squ=0,h=0,w=0;
    for(int i=l; i<=100; i++) {
        w = i;
        h=0;
        for(int j=1; j<=n; j++) {
            h+=a[j]/w;
        }
        squ = max(squ,w*h);
    }
    cout<<squ;
    return 0;
}


#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;

int n,l,ans,max_l;
int a[109];
int main(){
	in(n),in(l);L(i,0,n)in(a[i]),max_l=max(max_l,a[i]);
	L(i,l,max_l+1){
		int cnt=0;
		L(j,0,n){
			if(a[j]>=l){
				cnt+=a[j]/l;
			}
		}
		ans=max(ans,cnt*l);
	}
	cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;

int n,l,ans,max_l;
int a[109];
int main(){
	in(n),in(l);L(i,0,n)in(a[i]),max_l=max(max_l,a[i]);
	//~ D(max_l);
	L(i,l,max_l+1){
		int cnt=0;
		L(j,0,n){
			if(a[j]>=i){
				cnt+=a[j]/i;
			}
		}
		//~ D(cnt);D(l);
		if(cnt*i > 0)
			ans=max(ans,cnt*i);
	}
	cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;

ll n,l,ans,max_l;
ll a[109];
int main(){
	in(n),in(l);L(i,0,n)in(a[i]),max_l=max(max_l,a[i]);
	L(i,l,max_l+1){
		int cnt=0;
		L(j,0,n){
			if(a[j]>=l){
				cnt+=a[j]/l;
			}
		}
		if(cnt*l > 0)
			ans=max(ans,cnt*l);
	}
	cout<<ans<<endl;

	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;
#define ll long long
#define maxn 110
#define angel 0x3f3f3f3f
#define eps 1e-9
#define my_angel main
int n,l;
int num[maxn];
int my_angel()
{
    scanf("%d%d",&n,&l);
    for(int i=1;i<=n;i++)
        scanf("%d",&num[i]);
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=(num[i]/l);
    printf("%d\n",ans*l);
    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;
#define ll long long
#define maxn 110
#define angel 0x3f3f3f3f
#define eps 1e-9
#define my_angel main
int n,l;
int num[maxn];
int my_angel()
{
    scanf("%d%d",&n,&l);
    int maxx=-1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&num[i]);
        maxx=max(maxx,num[i]);
    }
    if(maxx<l)
    {
        printf("0\n");
        return 0;
    }
    int ans=0;
    for(int i=l;i<=maxx;i++)
    {
        int tmp=0;
        for(int j=1;j<=n;j++)
            tmp+=(num[j]/i);
        ans=max(ans,tmp*i);
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int a, b, c, ans;

int main(){
	scanf("%d %d", &a, &b);
	FI(i, 1, a){
		scanf("%d", &c);
		ans += b * (c / b);
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, l, s[105], ans;

int main(){
	scanf("%d %d", &n, &l);
	FI(i, 1, n) scanf("%d", &s[i]);
	FI(u, l, 100){
		int cur = 0;
		FI(i, 1, n) cur += u * (s[i] / u);
		ans = max(ans, cur);
	}
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;
int main() {
	vector<int> nums;
	int n, k;
	int temp;
	int m = -1;
	int mResult = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		if (temp > m) {
			m = temp;
		}
		nums.push_back(temp);
	}

	for (int i = k; i <= m; i++) {
		int sum = 0;
		for (int j = 0; j < nums.size(); j++) {
			sum += i * (nums[j] / i);
		}
		if (sum > mResult) {
			mResult = sum;
		}
	}

	cout << mResult << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
using namespace std;
int stripnumber[107];
int bigger_than[107];
int main()
{

    int n,minstrip;
    cin>>n>>minstrip;
    int nst;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&nst);
        stripnumber[nst]++;
    }
    for(int i=100;i>=1;i--)
    {
        bigger_than[i]=0;
        for(int j=i;j<=100;j++)
        {
            bigger_than[i]+=(j/i)*stripnumber[j];
        }
    }
    int ans=0;
    for(int s=minstrip;s<=100;s++)
    {
        int wind=s*bigger_than[s];
        ans=max(ans,wind);
    }
    cout<<ans<<endl;
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,x[101],tot,ans;
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",&x[i]);
	for(int i=m;i<101;i++)
	{
		tot=0;
		for(int j=0;j<n;j++)
			if(x[j]>=i)
				tot+=x[j]/i;
		ans=max(ans,tot*m);
	}
	printf("%d",ans);
}


#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,x[10001],tot,ans=-1;
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",&x[i]);
	for(int i=m;i<101;i++)
	{
		tot=0;
		for(int j=0;j<n;j++)
			tot+=x[j]/i;
		ans=max(ans,tot*i);
	}
	printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
int n,l,ans,mx,a[10005];
int main()
{
    scanf("%d%d",&n,&l);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=l;i<=100;i++)
    {
        ans=0;
        for(int j=1;j<=n;j++)
            ans+=a[j]/i;
        mx=max(mx,ans*i);
    }
    printf("%d",mx);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n,l,a[10001],i,j,k,ans=0;
   cin>>n>>l;
   for(i=0;i<n;i++){
      cin>>a[i];
   }
   for(i=l;i<101;i++){
      int u=0;
      for(j=0;j<n;j++){
         if(a[j]>=i) u+=(a[j]/i);
      }
      ans=max(ans,i*u);
   }
   cout<<ans;
}
//QwQ,It is Just a test


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fore(i,n) for(int i = 0; i< n ; i++ )
#define lop(i,n) for(int i = 1 ; i<=n ; i++ )
#define ops(i,n) for(int  i = n-1 ; i>=0 ; i-- )
#define forall( it,g )  for( typeof(g.begin()) it=g.begin();it!=g.end();it++ )
#define PI  3.141592653589793
#define mod  1000000007
#define inf 1000000000000000
#define INF -1000000000
#define modulo 1073741824
#define MH 1234533333333337
//ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using namespace std;
typedef vector <int > vi;
typedef vector <vector <int> > vv;
typedef vector <pair <int,int > >vp;
typedef vector <vector <pair <int ,int > > > vvp;
typedef vector <pair <int ,pair <int ,int > > > vpp;
typedef pair<int,int> pp;
typedef long long ll;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
  int n , l ;
  cin >> n >> l ;
  int a[n+1];
  fore(i , n)
    cin >> a[i];
  int ma = 0;
  sort(a,a+n);
  for(int i = l ;i<=100 ;i++){
    int sum = 0;
    for(int j = 0;j<n;j++)
      sum+=a[j]/i;
    ma = max(ma , sum * i);
  }
  cout << ma <<endl;
  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fore(i,n) for(int i = 0; i< n ; i++ )
#define lop(i,n) for(int i = 1 ; i<=n ; i++ )
#define ops(i,n) for(int  i = n-1 ; i>=0 ; i-- )
#define forall( it,g )  for( typeof(g.begin()) it=g.begin();it!=g.end();it++ )
#define PI  3.141592653589793
#define mod  1000000007
#define inf 1000000000000000
#define INF -1000000000
#define modulo 1073741824
#define MH 1234533333333337
//ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using namespace std;
typedef vector <int > vi;
typedef vector <vector <int> > vv;
typedef vector <pair <int,int > >vp;
typedef vector <vector <pair <int ,int > > > vvp;
typedef vector <pair <int ,pair <int ,int > > > vpp;
typedef pair<int,int> pp;
typedef long long ll;
bool v[12][12];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
  int n , l ;
  cin >> n >> l ;
  int a[n+1];
  fore(i , n)
    cin >> a[i];
  int ma = 0;
  sort(a,a+n);
  fore(i , n){
    if(a[i]>=l){
      int sum = 1;
      for(int j = i+1;j<n;j++){
        sum+=a[j]/a[i];
      }
      ma = max(ma , sum * a[i]);
    }
  }
  cout << ma <<endl;
  return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
using namespace std;
int n,m;
int main()
{

cin>>n>>m;
vector<int>v(n);
for(int i=0;i<n;i++)
cin>>v[i];
sort(v.begin(),v.end());
int ans=0;
for(int i=0;i<n;i++)
{
if(v[i]<m)
continue;
  int count=1;
  for(int j=i+1;j<n;j++)
  {
    count+=v[j]/v[i];
  }
ans=max(ans,count*v[i]);
}
cout<<ans;
  return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
using namespace std;
int n,m;
int main()
{

cin>>n>>m;
vector<int>v(n);
for(int i=0;i<n;i++)
cin>>v[i];
sort(v.begin(),v.end());
int ans=0;
for(int i=m;i<101;i++)
{
  int count=0;
  for(int j=0;j<n;j++)
  {
    count+=v[j]/i;
  }
ans=max(ans,count*i);
}
cout<<ans;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,l,ans,mx=-1,a[100001];
int main(){
    cin>>n>>l;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=l;i<=100;i++){
        ans=0;
        for(int j=1;j<=n;j++) ans=ans+a[j]/i;
        mx=max(mx,ans*i);
    }
    cout<<mx;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int a[110], n, l;

	cin >> n >> l;

	for(int i=0; i<n; i++)
		cin >> a[i];

	sort(a, a+n);

	int kd = 0;
	for(int i=l; i<=a[n-1]; i++) {
		int count = 0;
		for(int j=0; j<n; j++)
			count += a[j]/i;

		kd = max(kd, count * i);
	}

	cout << kd << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int a[110], n, l;

	cin >> n >> l;

	for(int i=0; i<n; i++)
		cin >> a[i];

	sort(a, a+n);

	int kd = 0;
	for(int i=l; i<=a[n-1]; i++) {
		int count = 0;
		for(int j=0; j<n; j++)
			count += a[j]/i;

		kd = max(kd, count * i)
	}

	cout << kd << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int a[110], n, l;

	cin >> n >> l;

	for(int i=0; i<n; i++)
		cin >> a[i];
	a[i] = -1;

	sort(a, a+n);

	int kd = 0;
	for(int i=l; i<=a[n-1]; i++) {
		int count = 0;
		for(int j=0; j<n; j++)
			count += a[j]/i;

		count = count * i;

		if(count > kd)
			kd = count;
	}

	cout << kd << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int a[110], n, l;

	cin >> n >> l;

	for(int i=0; i<n; i++)
		cin >> a[i];

	sort(a, a+n);

	int kd = 0;
	for(int i=l; i<=a[n-1]; i++) {
		int count = 0;
		for(int j=0; j<=n; j++)
			count += a[j]/i;

		count = count * i;

		if(count > kd)
			kd = count;
	}

	cout << kd << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int a[110], n, l;

	cin >> n >> l;

	for(int i=0; i<n; i++)
		cin >> a[i];

	sort(a, a+n);

	int kd = 0;
	for(int i=l; i<=a[n-1]; i++) {
		int count = 0;
		for(int j=0; j<n; j++)
			count += a[j]/i;

		count = count * i;

		if(count > kd)
			kd = count;
	}

	cout << kd << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[200],ans,mx;
int main()
{
	int n,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=l;i<=100;i++)
	{
		ans=0;
		for(int j=1;j<=n;j++)
		{
			ans=ans+a[j]/i;
		}
		mx=max(ans*i,mx);
	}
	cout<<mx;
}


#include <bits/stdc++.h>

using namespace std;
int n,l,i,a,ans;
int main()
{
    cin>>n>>l;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        ans+=a/l;
    }
    cout<<ans*l;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,l,i,Ans,j,a[110],ans;
int main()
{
    cin>>n>>l;
    for(i=1;i<=n;i++)cin>>a[i];
    for(i=l;i<=n;i++)
    {
        ans=0;
        for(j=1;j<=n;j++)
            ans+=a[j]/i;
        Ans=max(Ans,ans*i);
    }
    cout<<Ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n,l,i,Ans,j,a[110],ans;
int main()
{
    cin>>n>>l;
    for(i=1;i<=n;i++)cin>>a[i];
    for(i=l;i<=100;i++)
    {
        ans=0;
        for(j=1;j<=n;j++)
            ans+=a[j]/i;
        Ans=max(Ans,ans*i);
    }
    cout<<Ans;
    return 0;
}


/********************
* Problem: 0038C. Blinds
* Theme: Brute force
* Difficulty: 1400
*/
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,l,ans=0,mx=0,best=0;
    cin >> n >> l;
    int Z[n];
    for(int i=0; i < n; ++i) {
        cin >> Z[i];
        mx = max(mx,Z[i]);
    }
    for(;l<=mx;++l){
        ans=0;
        for(int i=0;i<n;++i)
            ans += Z[i]/l;
        best = max(best,ans*l);
    }
    cout << best << endl;
    return 0;
}


/********************
* Problem: 0038C. Blinds
* Theme: Brute force
* Difficulty: 1400
*/
#include <bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n,l,ans=0,x;
	cin >> n >> l;
	while(n--){
        cin >> x;
        ans += x / l;
	}
	cout << l*ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,l,ans=0,mx=-1,a[10005];
int main(){
    cin>>n>>l;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=l;i<=100;i++){
    	ans=0;
    	for(int j=1;j<=n;j++)
    		ans=ans+a[j]/i;
    	mx=max(mx,ans*i);
    }
    cout<<mx;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,l,ans=0,mx=-1,a[10005];
int main()
{
    cin>>n>>l;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    for(int i=l;i<=100;i++)
    {
    	ans=0;
    	for(int j=1;j<=n;j++)
    		ans=ans+a[j]/i;
    	mx=max(mx,ans*i);
    }
    cout<<mx;
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
const int N=107;
int a[N],ans,n,l;
int main(){
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		if(a[i]>=l){
			int su=0;
			for(int j=i;j<=n;j++)
				su+=a[j]/a[i];
			ans=max(ans,su*a[i]);
		}
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
const int N=107;
int a[N],ans,n,l;
int main(){
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=l;i<=100;i++){
		int su=0;
		for(int j=1;j<=n;j++)
			su+=a[j]/i;
		ans=max(ans,su*i);
	}
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int n, m;
int a[111];

int main() {
	scanf("%d%d", &n, &m);
	int ans=0;
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	for(int i=m;i<=100;i++) {
		int x = 0;
		for(int j=0;j<n;j++)
			x += a[j]/i*i;
		ans = max(ans, x);
	}
	printf("%d\n", ans);

	return 0;
}


#include<cstdio>

int n, m;

int main() {
	scanf("%d%d", &n, &m);
	int ans=0;
	for(int i=0;i<n;i++) {
		int x; scanf("%d", &x);
		ans += (x/m)*m;
	}
	printf("%d\n", ans);

	return 0;
}


//{
#include<bits/stdc++.h>
#define ll long long
#define pp pair<ll,ll>
#define fr(i,n) for(ll i=0;i<n;i++)
#define fi(i,j,n) for(ll i=j;i<=n;i++)
#define mod 1000003
#define pi acos(-1)
#define INF 1000000000
#define EPS 1e-9
using namespace std;
//}

int main()
{
    ll n,m,p,an=0,s;cin>>n>>m;ll a[n+1];
    fr(i,n)cin>>a[i];p=*max_element(a,a+n);

    fi(i,m,p)
    {s=0;
        fr(j,n)
        s+=(a[j]/i)*i;

        an=max(an,s);
    }
    cout<<an<<endl;
}


#include<stdio.h>

int main(int agrc, char *argv[]){
  int n, l; scanf("%d %d", &n, &l);
  int a[100];
  for(int i=0;i<n; i++)
    scanf("%d", a+i);
  int best = 0;
  for(int d=l; d<=100; d++){
    int k = 0;
    for(int i=0; i<n; i++)
      k += a[i]/d;
    if(k*d>best)
      best = k*d;
  }
  printf("%d", best);
  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define mp make_pair
#define ll long long
#define sqr(x) ((x)*(x))
using namespace std;

	int a[10][10], b[100010];
	ll mn=1e9, mx=-1e9, ans, cnt, sm;
	bool ok, okk, used[1000010], use[10010];

int main(){

    //freopen ("i.txt","r",stdin);
    //freopen ("o.txt","w",stdout);

    int n, l, x;
    vector <int> v;
    cin>>n>>l;
    for(int i=0;i<n;i++){
    	cin>>x;
    	if(x>=l){
    		v.pb(x);
    	}
    }
    sort(v.begin(), v.end());
    for(int i=0;i<sz(v);i++){
    	ans+=v[i]/v[0];
    }
    if(sz(v)==0){
    	cout<<0;
    	return 0;
    }
    cout<<ans*v[0];

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define mp make_pair
#define ll long long
#define sqr(x) ((x)*(x))
using namespace std;

	int a[10][10], b[100010];
	ll mn=1e9, mx=-1e9, ans, cnt, sm;
	bool ok, okk, used[1000010], use[10010];

int main(){

    //freopen ("i.txt","r",stdin);
    //freopen ("o.txt","w",stdout);

    int n, l, x;
    vector <int> v;
    cin>>n>>l;
    for(int i=0;i<n;i++){
    	cin>>x;
    	if(x>=l){
    		v.pb(x);
    	}
    }
    sort(v.begin(), v.end());
    for(int j=0;j<sz(v);j++){
    	ans=0;
    	for(int i=0;i<sz(v);i++){
    		ans+=v[i]/v[j];
    	}
    	mx=max(mx, ans*v[j]);
    }
   	if(sz(v)==0){
    	cout<<0;
    	return 0;
    }
    for(int i=0;i<sz(v);i++){
    	cnt+=v[i]/l;
    }
    cout<<max(mx, cnt*l);

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define mp make_pair
#define ll long long
#define sqr(x) ((x)*(x))
using namespace std;

	int a[10][10], b[100010];
	ll mn=1e9, mx=-1e9, ans, cnt, sm;
	bool ok, okk, used[1000010], use[10010];

int main(){

    //freopen ("i.txt","r",stdin);
    //freopen ("o.txt","w",stdout);

    int n, l, x;
    vector <int> v;
    cin>>n>>l;
    for(int i=0;i<n;i++){
    	cin>>x;
    	if(x>=l){
    		v.pb(x);
    	}
    }
    sort(v.begin(), v.end());
    for(int i=0;i<sz(v);i++){
    	ans+=v[i]/v[0];
    }
    if(sz(v)==0){
    	cout<<0;
    	return 0;
    }
    for(int i=0;i<sz(v);i++){
    	cnt+=v[i]/l;
    }
    cout<<max(ans*v[0], cnt*l);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[102],ans;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=d;i<101;i++){
		int s=0;
		for(int j=1;j<=n;j++)s+=a[j]/i;
		ans=max(ans,s);
	}
	cout<<ans*d;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[102],ans;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=d;i<101;i++){
		int s=0;
		for(int j=1;j<=n;j++)s+=a[j]/i;
		ans=max(ans,s*i);
	}
	cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n,l,res,cnt,a[100];

int main(){
	scanf("%d%d",&n,&l);
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	for(int i = l; i<100; i++){
		cnt = 0;
		for(int j=0; j<n; j++) cnt += a[j]/i;
		res = max(res,cnt*i);
	}
	printf("%d\n",res);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n,l,t,cnt;

int main(){
	scanf("%d%d",&n,&l);
	while(n--){
		scanf("%d",&t);
		cnt += t/l;
	}
	printf("%d\n",l*cnt);
	return 0;
}


//bismillahir rahmanir rahim            //Author:Fayed Anik

#include <bits/stdc++.h>

using namespace std;

#define         ll                         long  long
#define         lf                         double
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")

ll a[110];
int main(){
    ll n,x,mx=-1,cnt=0,t=0;
    sfl(n),sfl(x);
    for(ll i=1;i<=n;i++){
        sfl(a[i]);
    }
    for(ll len=x;len<=100;len++){
        cnt=0;
        for(ll i=1;i<=n;i++){
            cnt += a[i]/len;
        }

        if(cnt>mx){
            mx=cnt;
            t=len;
        }
    }
    cout<<mx*t<<endl;
}