Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll n,j=LLONG_MAX;
vector<pl>v;
void update(vector<ll> &ans, int i){
	j=min(j,v[i].se);
	if(i==0){
		ans[v[i].se]+=(n-i)*(v[i].fi);
		return;
	}
	ans[v[i].se]+=(n-i)*(v[i].fi-v[i-1].fi);

	update(ans,i-1);
}
 
int main(){
	cin>>n;
	vector<ll>a(n),ans(n);
	rep(i,n)cin>>a[i];
	rep(i,n)v.pb(mp(a[i],i));
	sort(all(v));
	update(ans,n-1);
	rep(i,n){
		cout<<ans[i]<<endl;
	}

    return 0;
}#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll n,j=LLONG_MAX;
vector<pl>v;
void update(vector<ll> &ans, int i){
	j=min(j,v[i].se);
	if(i==0){
		ans[v[i].se]+=(n-i)*(v[i].fi);
		return;
	}
	ans[v[i].se]+=(n-i)*(v[i].fi-v[i-1].fi);

	update(ans,i-1);
}
 
int main(){
	cin>>n;
	vector<ll>a(n),ans(n);
	rep(i,n)cin>>a[i];
	rep(i,n)v.pb(mp(a[i],i));
	sort(all(v));
	update(ans,n-1);
	rep(i,n){
		cout<<ans[i]<<endl;
	}

    return 0;
}

Compiler output:
a.cc:53:2: error: stray '#' in program
   53 | }#include <iostream>
      |  ^
a.cc:53:3: error: 'include' does not name a type
   53 | }#include <iostream>
      |   ^~~~~~~
a.cc:80:4: error: redefinition of 'll n'
   80 | ll n,j=LLONG_MAX;
      |    ^
a.cc:28:4: note: 'll n' previously declared here
   28 | ll n,j=LLONG_MAX;
      |    ^
a.cc:80:6: error: redefinition of 'll j'
   80 | ll n,j=LLONG_MAX;
      |      ^
a.cc:28:6: note: 'll j' previously defined here
   28 | ll n,j=LLONG_MAX;
      |      ^
a.cc:81:11: error: redefinition of 'std::vector<std::pair<long long int, long long int> > v'
   81 | vector<pl>v;
      |           ^
a.cc:29:11: note: 'std::vector<std::pair<long long int, long long int> > v' previously declared here
   29 | vector<pl>v;
      |           ^
a.cc:82:6: error: redefinition of 'void update(std::vector<long long int>&, int)'
   82 | void update(vector<ll> &ans, int i){
      |      ^~~~~~
a.cc:30:6: note: 'void update(std::vector<long long int>&, int)' previously defined here
   30 | void update(vector<ll> &ans, int i){
      |      ^~~~~~
a.cc:93:5: error: redefinition of 'int main()'
   93 | int main(){
      |     ^~~~
a.cc:41:5: note: 'int main()' previously defined here
   41 | int main(){
      |     ^~~~