#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

////////////////////////////////////////////////////

// Function to return the sum of arr[0..index]
// This function assumes that the array is preprocessed 
// and partial sums of array elements are stored in BITree[]
int getSum(int BITree[], int index)
{
    int sum = 0; // Initialize result
 
    // Traverse ancestors of BITree[index]
    while (index > 0) {
        // Add current element of BITree to sum
        sum += BITree[index];
 
        // Move index to parent node in getSum View
        index -= index & (-index);
    }
    return sum;
}
 
// Updates a node in Binary Index Tree (BITree) at given index
// in BITree. The given value 'val' is added to BITree[i] and
// all of its ancestors in tree.
void updateBIT(int BITree[], int n, int index, int val)
{
    // Traverse all ancestors and add 'val'
    while (index <= n) {
 
        // Add 'val' to current node of BI Tree
        BITree[index] += val;
 
        // Update index to that of parent in update View
        index += index & (-index);
    }
}

///////////////////////////////////////////////////


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
    vi a(n);
    forn(i,n) cin>>a[i];
    // vi s;
    int BIT[n + 1];
    for (int i = 1; i <= n; i++)
        BIT[i] = 0;
 
    vi suff(n,0);
    // s.pb(a[n-1]);
    ll ans = 0;

    for (int i = n - 1; i >= 0; i--) {
 
        // Get count of elements smaller than arr[i]
        suff[i] = getSum(BIT, a[i]);
        ans += suff[i];
        // Add current element to BIT
        updateBIT(BIT, n, a[i]+1, 1);
    }

    // for(int i=n-2;i>=0;i--)
    // {
    //     auto it = lower_bound(all(s),a[i]);
    //     int h = it - s.begin();
    //     suff[i] = h;
    //     // it--;
    //     ans += h;
    //     s.insert(it,a[i]);
    //     // for(auto it:s) cout<<it<<':'; cout<<endl;
    // }
    // forn(i,n) cout<<suff[i]<<' ';
    cout<<ans<<'\n';
    int sz = 0;
    forn(i,n-1)
    {
        // auto it = lower_bound(all(s),a[i]);
        int h = a[i] - suff[i];
        ans += (n-1-i-2*suff[i]);
        ans -= h;
        ans += (sz-h);
        // s.insert(it,a[i]);
        sz++;
        // for(auto it:s) cout<<it<<':'; cout<<endl;
        cout<<ans<<'\n';
    }


	return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
// #include <atcoder/all>
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<ll>;
using ss = string;
using db = double;
template<class T> using minpq = priority_queue <T,vector<T>,greater<T>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
#define V vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define reciv(v,n) vi (v)((n)); rep(i,0,(n))cin>>v[i]
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ci(x) cin >> x
#define pb push_back
#define eb emplace_back
#define rz resize
#define sz(x) int(x.size())
#define yn cout<<"Yes"<<endl;else cout<<"No"<<endl
#define YN cout<<"YES"<<endl;else cout<<"NO"<<endl
template<class T>void chmax(T &x,T y){x=max(x,y);}
template<class T>void chmin(T &x,T y){x=min(x,y);}
template<class T>void allv(V<T> v){for(T NUM:v)printf("%d ",NUM);printf("\n");}

int main(){
    ll  a, b ;	cin>> a >> b ;
    ll  c, d ;	cin>> c >> d ;

    ll cdb=c*d-b;
    ll ans=1001001001;
    if(cdb<=0)ans=-1;
    
    else ans=(a+cdb-1)/cdb;

    cout<< ans <<endl;
    
}