#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxn 200005
int n;
ll a[maxn],sum[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]),sum[i]=sum[i-1]+a[i];
	
	ll summ=0,maxx=a[1];
	for(int i=1;i<=n;i++){
		summ+=sum[i-1];maxx=max(maxx,a[i]);
		ll ans=summ+i*maxx+sum[i];
		printf("%lld\n",ans);
	}
	
	
	
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define p(x,y) pair<x,y>
#define oset(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define scan(a) for(auto &it:a)cin>>it;
#define print(a) {for(auto it:a)cout<<it<<" ";cout<<endl;}
#define out(x) cout<<((x)?"YES":"NO")<<endl;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define int ll

void solve()
{
  int n;
  cin>>n;
  vector<pair<double,double>> a;
  rep(i,0,n)
  {
    double t,l,r;
    int t1,l1,r1;
    cin>>t1>>l1>>r1;
    t=t1;r=r1;l=l1;
    if(t==2)
        r-=0.4;
    else if(t==3)
        l+=0.4;
    else if(t==4)
        l+=0.4,r-=0.4;
    a.push_back(make_pair(l,r));
    // cout<<a[i].first<<" ";
  }
  int ans=0;
  rep(i,0,n)
  {
    if(a[i].first==-1)
        continue;
    double l1=a[i].first,r1=a[i].second,l2,r2;
    rep(j,i+1,n)
    {
        l2=a[j].first;r2=a[j].second;
        if(r1<l2||r2<l1)
            continue;
        ans++;
    }
  }
  cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t=1;
    //init();
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
