stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define name ""

#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)

#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)

#define long long long 

#define db double 

#define pii pair <int, int>

#define pll pair <long, long>

#define all(c) c.begin(), c.end()

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)



const int INF = 1e9+7;

const int MOD = 1e9+7;

const int dx[4] = {0,0,-1,1};

const int dy[4] = {-1,1,0,0};



const int N = 1e5+1;



int n, a[N], val[N], b[N];

long res[N];

vector <int> pos[N];



int main()

{

	fastio;

	cin >> n;

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

	sort(a + 1, a + 1 + n);

	for (int i = 1; i <= n; i++){

		int x = lower_bound(a + 1, a + 1 + n, b[i]) - a;

		val[x] = b[i];

		pos[x].push_back(i);

	}

	int pre = -INF, x = INF;

	long cnt = 0;

	for (int i = n; i >= 0; i--){

		if (i == 0){

			res[x] += cnt * pre;

			break;

		}

		if (pos[i].size() == 0) continue;

		if (pre == -INF){

			x = pos[i][0];

			pre = val[i];

			cnt += pos[i].size();

		}	

		else {

			res[x] += cnt * (pre - val[i]);

			if (pos[i][0] < x) x = pos[i][0];

			cnt += pos[i].size();

			pre = val[i];

		}

	}

	for (int i = 1; i <= n; i++) cout << res[i] << '\n';

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.592582624991222x):
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

typedef pair<int, int> pii;

int a[100005];

LL ans[100005];

pii p[100005];

int main(){

    int n;

    scanf("%d", &n);

    for(int i=1;i<=n;i++){

        scanf("%d", &a[i]);

        p[i] = pii(a[i], -i);

    }

    p[n+1] = pii(0, 0);

    sort(p+1, p+1+n);

    reverse(p+1, p+1+n);



    int mn = 1e9;

    for(int i=1;i<=n;i++){

        mn = min(mn, -p[i].second);

        if(a[-p[i].second] != a[-p[i+1].second]){

            int d = a[-p[i].second]-a[-p[i+1].second];

            ans[mn] += d*1ll*i;

        }

    }

    for(int i=1;i<=n;i++) printf("%lld\n", ans[i]);

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define int long long

#define Rep(i, N) for(int i = 0; i < N; i++)

#define Reps(i, x, N) for(int i = x; i < N; i++)

typedef pair<int, int> Pi;

#define fi first

#define se second



const int LLINF = 1LL << 60;



signed main()

{

  int N;

  Pi A[100005];

  int out[100005] = {0};



  cin >> N;

  A[N].fi = 0, A[N].se = -1;

  Rep(i, N) {

    cin >> A[i].fi; A[i].se = i;

  }



  sort(A, A + N + 1, greater< Pi >());



  int minv = LLINF;

  int i = 0;

  while(i < N) {

    int save = A[i].fi;

    while(save == A[i].fi && i < N) i++;

    minv = min(A[i - 1].se, minv);

    //cout << i << " " << minv << " " << A[i - 1].fi << endl;

    out[minv] += i * (A[i - 1].fi - A[i].fi);

  }



  Rep(i, N) {

    cout << out[i] << endl;

  }



  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.887865632976874x):
#include <bits/stdc++.h>

using namespace std;



using ll = long long;

using Pi = pair<int, int>;

using Pl = pair<ll, ll>;

using vint = vector<int>;

using vll = vector<ll>;

template<typename T> using uset = unordered_set<T>;

template<typename T1, typename T2> using umap = unordered_map<T1, T2>;



constexpr int INF = (1 << 30) - 1;

constexpr ll LLINF = 1LL << 60;

constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};

constexpr char el = '\n';

constexpr int mod = 1000000007;



template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }

template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }



int main() {

        ll N;

        ll ans[100005] = {};

        map<ll,Pl> mp;



        cin >> N;

        for (ll i = 1; i <= N; i++) {

                ll a;

                cin >> a;

                if (mp.find(a) == mp.end()) mp[a].first = i;

                mp[a].second++;

        }



        ll total = 0;

        ll minv = N;

        for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {

                auto v = *itr;

                auto it2 = itr;

                it2++;



                ll prev;

                if (it2 == mp.rend()) prev = 0;

                else prev = it2->first;



                total += v.second.second; 

                minv = min(minv, v.second.first);

                ans[minv] += total * (v.first - prev);

        }



        for (ll i = 1; i <= N; i++) {

                cout << ans[i] << el;

        }



        return (0);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=100002;

struct node{

	int x,id;

}a[N];

int n,i,id[N],cnt,b[N],mx[N];

ll ans[N];

inline char gc(){

	static char buf[100000],*p1=buf,*p2=buf;

	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;

}

inline int rd(){

	int x=0,fl=1;char ch=gc();

	for (;ch<48||ch>57;ch=gc())if(ch=='-')fl=-1;

	for (;48<=ch&&ch<=57;ch=gc())x=(x<<3)+(x<<1)+(ch^48);

	return x*fl;

}

inline void wri(ll a){if(a<0)a=-a,putchar('-');if(a>=10)wri(a/10);putchar(a%10|48);}

inline void wln(ll a){wri(a);puts("");}

bool cmp(node a,node b){return a.x<b.x || a.x==b.x && a.id<b.id;}

int main(){

	n=rd();

	for (i=1;i<=n;i++) a[i].x=rd(),a[i].id=i;

	sort(a+1,a+n+1,cmp);

	id[++cnt]=a[1].id;b[1]=1;mx[1]=a[1].x;

	for (i=2;i<=n;i++)

		if (a[i].x==a[i-1].x) b[cnt]++;

		else id[++cnt]=a[i].id,b[cnt]=1,mx[cnt]=a[i].x;

	for (i=cnt;i;i--) ans[id[i]]+=1ll*b[i]*(mx[i]-mx[i-1]),b[i-1]+=b[i],id[i-1]=min(id[i-1],id[i]);

	for (i=1;i<=n;i++) wln(ans[i]);

}

// Faster C++ solution for the same problem (measured speedup: 5.145329642801708x):
#include <cstdio>

#include <cctype>

#include <cstring>

#include <algorithm>

int read(){

	register int x = 0;

	register char f = 1, ch = getchar();

	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = 0;

	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');

	return f ? x : -x;

}

int n;

struct node{

	int val, id;

	bool operator < (const node &b) const {

		return val > b.val || val == b.val && id < b.id;

	}

}a[100005];

long long ans[100005];

int main(){

	n = read();

	for (register int i = 1; i <= n; ++i) a[i] = (node){read(), i};

	std :: sort(a + 1, a + 1 + n);

	for (register int i = 1, j, k = 0x3f3f3f3f; i <= n; i = j){

		for (j = i; j <= n && a[j].val == a[i].val; ++j) ;

		k = std :: min(k, a[i].id);

		ans[k] += 1ll * (j - 1) * (a[i].val - a[j].val);

	}

	for (register int i = 1; i <= n; ++i) printf("%lld\n", ans[i]);

}
// Slower C++ solution:
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")

#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>

#define For(i,j,k)	for(int i=j;i<=k;++i)

#define Dow(i,j,k)	for(int i=k;i>=j;--i)

#define ll long long

#define int ll

#define pb push_back





using namespace std;



inline ll read()

{

    ll t=0,dp=1;char c=getchar();

    while(!isdigit(c))	{if(c=='-')	dp=-1;c=getchar();}

    while(isdigit(c))	t=t*10+c-48,c=getchar();

    return t*dp;

}

inline void write(ll x){if(x<0)	{putchar('-');x=-x;}	if(x>=10)	write(x/10);putchar(x%10+48);}

inline void writeln(ll x){write(x);puts("");}

inline void write_p(ll x){write(x);putchar(' ');}

/*------------------------------------------------------------------------------------------------------*/



const int N=1e5+5;	

int n;

struct node{int v,num;}	p[N];

int ans[N];

inline bool cmp(node x,node y){return x.v!=y.v?x.v>y.v:x.num<y.num;}

signed main()

{

	n=read();

	For(i,1,n)	p[i].v=read(),p[i].num=i;

	sort(p+1,p+n+1,cmp);

	int now=1,to=p[1].num;

//	For(i,1,n)	cout<<p[i].v<<' '<<p[i].num<<endl;

	For(i,2,n+1)

	{

		ans[to]+=(p[i-1].v-p[i].v)*now,now++;

		to=min(to,p[i].num);

	}

//	ans[to]=(p[n].v-p[n+1].v)*now,now++;

	For(i,1,n)	writeln(ans[i]);

}

// Faster C++ solution for the same problem (measured speedup: 5.143816316382955x):
#include <cstdio>

#include <cctype>

#include <cstring>

#include <algorithm>

int read(){

	register int x = 0;

	register char f = 1, ch = getchar();

	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = 0;

	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');

	return f ? x : -x;

}

int n;

struct node{

	int val, id;

	bool operator < (const node &b) const {

		return val > b.val || val == b.val && id < b.id;

	}

}a[100005];

long long ans[100005];

int main(){

	n = read();

	for (register int i = 1; i <= n; ++i) a[i] = (node){read(), i};

	std :: sort(a + 1, a + 1 + n);

	for (register int i = 1, j, k = 0x3f3f3f3f; i <= n; i = j){

		for (j = i; j <= n && a[j].val == a[i].val; ++j) ;

		k = std :: min(k, a[i].id);

		ans[k] += 1ll * (j - 1) * (a[i].val - a[j].val);

	}

	for (register int i = 1; i <= n; ++i) printf("%lld\n", ans[i]);

}
// Slower C++ solution:
#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<vector>

#define LL long long

using namespace std;

const int maxn=1e5+10;

struct node

{

    LL pos,val;

} a[maxn];

bool cmp(node a,node b)

{

    if(a.val==b.val)return a.pos<b.pos;

    return a.val>b.val;

}

int n;

LL ans[maxn];

int main()

{

    while(scanf("%d",&n)!=EOF)

    {

        memset(ans,0,sizeof ans);

        for(int i=1; i<=n; i++)

        {

            scanf("%lld",&a[i].val);

            a[i].pos=i;

        }

        sort(a+1,a+n+1,cmp);

        a[n+1].val=0;

        LL tmp=1;

        int num=a[1].pos;

        for(int i=2; i<=n+1; i++)

        {

            if(a[i].val==a[i-1].val) tmp++;

            else ans[num]+=(a[i-1].val-a[i].val)*tmp,tmp++;

            if(a[i].pos<num) num=a[i].pos;

        }

        for(int i=1;i<=n;i++)printf("%lld\n",ans[i]);

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.200605319218014x):
#include <cstdio>

#include <cctype>

#include <cstring>

#include <algorithm>

int read(){

	register int x = 0;

	register char f = 1, ch = getchar();

	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = 0;

	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');

	return f ? x : -x;

}

int n;

struct node{

	int val, id;

	bool operator < (const node &b) const {

		return val > b.val || val == b.val && id < b.id;

	}

}a[100005];

long long ans[100005];

int main(){

	n = read();

	for (register int i = 1; i <= n; ++i) a[i] = (node){read(), i};

	std :: sort(a + 1, a + 1 + n);

	for (register int i = 1, j, k = 0x3f3f3f3f; i <= n; i = j){

		for (j = i; j <= n && a[j].val == a[i].val; ++j) ;

		k = std :: min(k, a[i].id);

		ans[k] += 1ll * (j - 1) * (a[i].val - a[j].val);

	}

	for (register int i = 1; i <= n; ++i) printf("%lld\n", ans[i]);

}
// Slower C++ solution:
// AtCoder Regular Contest 069

// E - Frequency



#include <cstdio>

#include <cstring>

#include <queue>

#define MAX_N 100000

using namespace std;

typedef long long int ll;

typedef pair<ll, int> PLI;





int N;

priority_queue<PLI> q;

ll ans[MAX_N];



int main() {



  PLI p;

  ll a, cnt;

  int min_i;



  scanf("%d", &N);

  q.push(PLI(0, -1));

  for (int i = 0; i < N; i++) {

    scanf("%lld", &a);

    q.push(PLI(a, i));

  }

  memset(ans, 0, sizeof(ans));



  min_i = N;

  cnt = 0;

  while (q.size() > 1) {

    p = q.top(); q.pop();

    min_i = min(min_i, p.second);

    ans[min_i] += (p.first - q.top().first) * (cnt + 1);

    cnt++;

  }



  for (int i = 0; i < N; i++) {

    printf("%lld\n", ans[i]);

  }



  return 0;



}






// Faster C++ solution for the same problem (measured speedup: 1.7432062639840524x):
// AtCoder Regular Contest 069

// E - Frequency



#include <cstdio>

#include <cstring>

#include <algorithm>

#define MAX_N 100000

using namespace std;

typedef long long int ll;

typedef pair<ll, int> PLI;





int N;

PLI m[MAX_N + 1];

ll ans[MAX_N];



int main() {



  ll cnt;

  int min_i;



  scanf("%d", &N);

  for (int i = 0; i < N; i++) {

    scanf("%lld", &m[i].first);

    m[i].second = i;

  }

  m[N] = PLI(0, -1);

  memset(ans, 0, sizeof(ans));

  sort(m, m + N + 1);



  min_i = N;

  cnt = 0;

  for (int i = N; i > 0; i--) {

    min_i = min(min_i, m[i].second);

    ans[min_i] += (m[i].first - m[i - 1].first) * (cnt + 1);

    cnt++;

  }



  for (int i = 0; i < N; i++) {

    printf("%lld\n", ans[i]);

  }



  return 0;



}
// Slower C++ solution:
#include <bits/stdc++.h>

#define REP(i,a,b) for(int i=(a);i<(b);i++)

#define RREP(i,a,b) for(int i=(a);i>=(b);i--)

#define pq priority_queue

#define P pair<int,int>

#define P2 pair<int,P>

#define P3 pair<int,P2>

typedef long long ll; typedef long double ld;

using namespace std;

const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};

const ll LINF=1e18;

const ld PI=abs(acos(-1));



int a[100010];

vector<P> vec;



int main(){

	int n; cin >> n;

	REP(i,0,n) cin >> a[i], vec.push_back({a[i], i});

	vec.push_back({0, n});

	sort(vec.rbegin(), vec.rend());

	

	ll mi = n, li[100010] = {};

	REP(i,0,n){

		mi = min<ll>(mi, vec[i].second);

		li[mi] += (ll)(i+1) * (vec[i].first - vec[i+1].first);

	}

	

	REP(i,0,n) cout << li[i] << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7919915843479064x):
#include <bits/stdc++.h>

using std::cout;

using std::endl;

using std::cin;



int main(){

	int n; cin >> n;

	std::priority_queue<std::pair<long, int>> qu;

	for(int i = 0; i < n; i++){

		int a; cin >> a;

		

		qu.push({a, i});

	}

	qu.push({0, n});

	

	std::vector<long> ans(n, 0); long c = 1; int pos = 1e9;

	while(!qu.empty()){

		auto p = qu.top(); qu.pop();

		auto q = qu.top();

		

		pos = std::min(pos, p.second);

		

		long dist = p.first - q.first;

		ans[pos] += dist * c; c++;

	}

	

	for(int i = 0; i < n; i++) cout << ans[i] << endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

typedef long long ll;

typedef double db;

#define pa pair<int,int>

#define mk make_pair

#define LOG(format, args...) fprintf(stderr, format, args)

using namespace std;

inline int rd() {

	int x=0,f=1;char ch=getchar();

	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;

	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';

	return x*f;

}

const int MAXN=5e5+100;

ll N,a[MAXN];

ll l[MAXN];

ll but[MAXN],idx[MAXN];

ll ans[MAXN];

//main========================

int main() {

	memset(idx,0x3f,sizeof idx);

	N=rd();

	for(int i=1;i<=N;++i) a[i]=rd(),l[++*l]=a[i];

	sort(l+1,l+*l+1);

	*l=unique(l+1,l+*l+1)-l-1;

	for(int i=1;i<=N;++i) a[i]=lower_bound(l+1,l+*l+1,a[i])-l;

	for(int i=1;i<=N;++i) but[a[i]]++,idx[a[i]]=min((ll)i,idx[a[i]]);

	for(int i=*l;i>=1;--i) if(but[i]) {

		but[i-1]+=but[i];

		idx[i-1]=min(idx[i],idx[i-1]);

		ans[idx[i]]+=(ll)(l[i]-(i>1?l[i-1]:0) )*but[i];

	} 

	for(int i=1;i<=N;++i) printf("%lld\n",ans[i]);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 26.063731023651098x):
#include<cstdio>

#include<algorithm>

#define int long long

using namespace std;

struct arr

  {

   int aa,bb;

  }a[100010];

int n;

long long b[100010];

int cmp(arr x,arr y)

  {

   if (x.aa!=y.aa) return x.aa>y.aa;

   return x.bb<y.bb;

  }

signed main()

  {

   scanf("%lld",&n);

   for (int i=1;i<=n;i++)

     {

      scanf("%lld",&a[i].aa);

      a[i].bb=i;b[i]=0;

	 }

   sort(a+1,a+1+n,cmp);

   int maxa=1;int maxb=1;

   while (true)

     {

      while ((a[maxb].aa==a[maxa].aa) && (maxb<=n)) maxb=maxb+1;

      if (maxb>n) break;

      b[a[maxa].bb]+=(maxb-1)*(a[maxa].aa-a[maxb].aa);

      a[maxa].aa=a[maxb].aa;

	  if (a[maxa].bb>a[maxb].bb) maxa=maxb;

	 }

   b[a[maxa].bb]+=a[maxa].aa*n;

   for (int i=1;i<=n;i++) printf("%lld\n",b[i]);

   return 0;

  }
// Slower C++ solution:
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

 

using namespace std;

using namespace __gnu_pbds;

 

#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key

 

typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<int> vi;

typedef long double ld; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;



bool cmp(ii a, ii b)

{

	if(a.fi!=b.fi) return a.fi>b.fi;

	else return a.se>b.se;

}



vector<ii> vec;

ll ans[100001];



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	int n; cin>>n;

	vec.resize(n);

	ll sum = 0;

	for(int i = 0; i < n; i++)

	{

		ll x; cin>>x;

		vec[i].fi=x;vec[i].se=i;

		sum+=x;

	}

	sort(vec.begin(),vec.end(),cmp);

	ll weight = 0;

	for(int i = 0; i < vec.size(); i++)

	{

		ll cnt = vec[i].fi; ll idx = vec[i].se;

		if(i+1<vec.size()&&vec[i+1].fi==vec[i].fi)

		{

			weight++;

			continue;

		}

		if(i==int(vec.size()) - 1)

		{

			ans[idx]+=cnt*(weight+1);

			break;

		}

		int ptr = i + 1;

		int nxtval = vec[ptr].fi;

		int ext = 1;

		while(ptr<n&&vec[ptr].fi==nxtval)

		{

			ext++;

			ptr++;

		}

		ptr--;

		ext--;

		if(vec[ptr].se<idx)

		{

			ans[idx]+=(cnt-(nxtval+1))*(weight+1)+1+weight;

			weight++;

			continue;

		}

		ans[idx]+=(cnt-nxtval)*(weight+1);

		vec[ptr].se=idx;

		i=ptr-1;

		weight+=ext;

		continue;

	}

	for(int i=0;i<n;i++)

	{

		cout<<ans[i]<<'\n';

	}

}


// Faster C++ solution for the same problem (measured speedup: 5.2302451687078255x):
#include<cstdio>

#include<algorithm>

#include<cstring>

#define MN 100005

using namespace std;

int n,a[MN],px[MN];long long ans[MN];

bool cmp(int x,int y){return a[x]==a[y]?x<y:a[x]>a[y];}

int main(){	

	scanf("%d",&n);

	for(int i=1;i<=n;i++)scanf("%d",&a[i]),px[i]=i;sort(px+1,px+n+1,cmp);int now=px[1],sum=0;

	for(int i=1,j=1;i<=n;i=j){

		for(;j<=n;j++)if(a[px[j+1]]!=a[now])break;now=min(now,px[i]),sum+=j-i+1;

		ans[now]+=1ll*(a[px[i]]-a[px[j+1]])*sum;j++;

	}

	for(int i=1;i<=n;i++)printf("%lld\n",ans[i]);

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int ll

//{ PXH612

using namespace std;

#define ll long long

#define db double

#define pp pair<int,int>

#define x first

#define y second



#define false(x) if(!(x))

template<typename A,typename B>bool Min(A &a,B b){if(a<=b) return 0;a=b;return 1;}

template<typename A,typename B>bool Max(A &a,B b){if(a>=b) return 0;a=b;return 1;}

#define in ({ll x=0;int o=0,c=char(),t=0;for(;!isdigit(c)&&t<1000;c=getchar(),t++) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})

#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})



#define FOR(i,a,b) for(int i=a,ENDFOR=b;i<=ENDFOR;i++)

#define ROF(i,a,b) for(int i=b,ENDFOR=a;ENDFOR<=i;i--)

#define RR(x,a,b) {cout<<#x<<": ";FOR(_,a,b) cout<<x[_]<<" ";cout<<"\n";}

#define rr(x) " "<<#x<<'='<<(x)<<" "



#define VEC(i,a) for(auto&i:a)

#define pb push_back

#define vn(a) (int)a.size()-1



#define bit(x,i) ((x>>(i-1))&1ll)

#define on(x,i) (x|(1ll<<(i-1)))

#define off(x,i) (x&~(1ll<<(i-1)))

#define mu(x) (1ll<<x)

#define bitnum(x) __builtin_popcountll(x)



#define segg(a,b) (abs(a-b)+1)

#define midd(a,b) (a+(b-(a))/2)

#define mems(x,a) memset(x,a,sizeof x)

#define open(a) freopen(a,"r",stdin)

#define shut(b) freopen(b,"w",stdout)

//}/////////////////////////////////////////////////////}



const int N=1e5+5;

int n;

int a[N],ans[N];

vector<int> e[N],v;



int low(int x){return lower_bound(v.begin(),v.end(),x)-v.begin();}

main()

{

  // open("frequency.inp");

    n=in;

    FOR(i,1,n) a[i]=in;

    FOR(i,1,n) v.pb(a[i]);



    v.pb(0);



    sort(v.begin(),v.end());

    v.erase(unique(v.begin(),v.end()),v.end());

    FOR(i,1,n) e[low(a[i])].pb(i);



    int cnt=0,mn=INT_MAX;

   // cout<<rr(v[0]) rr(v[1]) "\n";

    ROF(i,1,vn(v)) if(e[i].size())

    {

        VEC(j,e[i]) Min(mn,j);

        cnt+=e[i].size();

        ans[mn]+=cnt*(v[i]-v[i-1]);

    }

    FOR(i,1,n) cout<<ans[i]<<"\n";

}


// Faster C++ solution for the same problem (measured speedup: 3.454649385629574x):
#include <bits/stdc++.h>



using namespace std;



#define int long long



typedef pair<int,int> ii;



map<int,int> cnt, first_pos;

priority_queue<int> pq;



int n;

int a[100001], ans[100001];



int32_t main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);



	cin >> n;

	int pre = -1;

	for (int i=1;i<=n;i++)

	{

		cin >> a[i];

		if (!cnt.count(a[i]))

		{

			pq.push(a[i]);

			first_pos[a[i]] = i;

		}	

		cnt[a[i]]++;

	}

	while(!pq.empty())

	{

		if (first_pos[pq.top()] == 1)

		{

			ans[1] += cnt[pq.top()]*pq.top();

			pq.pop();

			while(!pq.empty())

			{

				ans[1] += cnt[pq.top()]*pq.top();

				pq.pop();

			}			

		}

		else

		{

			int cur_pos = first_pos[pq.top()];

			int cur_val = pq.top();

			pq.pop();

			ans[cur_pos] += cnt[cur_val]*(cur_val - pq.top());

			if(first_pos[pq.top()] > cur_pos)

				first_pos[pq.top()] = cur_pos;

			cnt[pq.top()] += cnt[cur_val];

		}

	}

	for (int i=1;i<=n;i++)

		cout << ans[i] << '\n';

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int ll

//{ PXH612

using namespace std;

#define ll long long

#define db double

#define pp pair<int,int>

#define x first

#define y second



#define false(x) if(!(x))

template<typename A,typename B>bool Min(A &a,B b){if(a<=b) return 0;a=b;return 1;}

template<typename A,typename B>bool Max(A &a,B b){if(a>=b) return 0;a=b;return 1;}

#define in ({ll x=0;int o=0,c=char(),t=0;for(;!isdigit(c)&&t<1000;c=getchar(),t++) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})

#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})



#define FOR(i,a,b) for(int i=a,ENDFOR=b;i<=ENDFOR;i++)

#define ROF(i,a,b) for(int i=b,ENDFOR=a;ENDFOR<=i;i--)

#define RR(x,a,b) {cout<<#x<<": ";FOR(_,a,b) cout<<x[_]<<" ";cout<<"\n";}

#define rr(x) " "<<#x<<'='<<(x)<<" "



#define VEC(i,a) for(auto&i:a)

#define pb push_back

#define vn(a) (int)a.size()-1



#define bit(x,i) ((x>>(i-1))&1ll)

#define on(x,i) (x|(1ll<<(i-1)))

#define off(x,i) (x&~(1ll<<(i-1)))

#define mu(x) (1ll<<x)

#define bitnum(x) __builtin_popcountll(x)



#define segg(a,b) (abs(a-b)+1)

#define midd(a,b) (a+(b-(a))/2)

#define mems(x,a) memset(x,a,sizeof x)

#define open(a) freopen(a,"r",stdin)

#define shut(b) freopen(b,"w",stdout)

//}/////////////////////////////////////////////////////}



const int N=1e5+5;

int n;

int a[N],ans[N];

vector<int> e[N],v;



int low(int x){return lower_bound(v.begin(),v.end(),x)-v.begin();}

main()

{

  // open("frequency.inp");

    n=in;

    FOR(i,1,n) a[i]=in;

    FOR(i,1,n) v.pb(a[i]);



    v.pb(0);



    sort(v.begin(),v.end());

    v.erase(unique(v.begin(),v.end()),v.end());

    FOR(i,1,n) e[low(a[i])].pb(i);



    int cnt=0,mn=INT_MAX;

   // cout<<rr(v[0]) rr(v[1]) "\n";

    ROF(i,1,vn(v)) if(e[i].size())

    {

        VEC(j,e[i]) Min(mn,j);

        cnt+=e[i].size();

        ans[mn]+=cnt*(v[i]-v[i-1]);

    }

    FOR(i,1,n) cout<<ans[i]<<"\n";

}


// Faster C++ solution for the same problem (measured speedup: 3.466254606617975x):
#include <bits/stdc++.h>



using namespace std;

long long n,kq[100005],sl,x;

set<int> s;

pair<long long,int> a[100005];

int main()

{

  

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    cin>>n;

    for (int i=1;i<=n;++i)

    {

        cin>>a[i].first;

        a[i].second=i;

    }

    sort(a+1,a+n+1);

    s.insert(a[n].second);

    sl=a[n].first;

    for (int i=n-1;i>=0;--i)

     if (a[i].first==sl) s.insert(a[i].second);

    else

    {

        x=s.size();

        kq[(*s.begin())]+=(x*(sl-a[i].first));

        sl=a[i].first;

        s.insert(a[i].second);



    }



    for (int i=1;i<=n;++i) cout<<kq[i]<<'\n';

    return 0;

}