//#include "HEADERS.h"
//sleepy 's trend
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define     TCOUNT         printf("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
#define     FAST_IO 	ios_base::sync_with_stdio(false); cin.tie(0);
#define     READ        freopen("input.txt", "r", stdin);
#define     WRITE       freopen("output.txt", "w", stdout);

#define     str_to_int(stroka)      atoi(stroka.c_str())
#define     str_to_ll(stroka)       atoll(stroka.c_str())
#define     str_to_double(stroka)   atof(stroka.c_str()

#define 	REP(i,n)    for(__typeof(n) i=0; i<n; i++)// [0, n)
#define 	FOR(i,a,b)  for(__typeof(b) i=a; i<=b; i++)// [a, b]
#define 	ROF(i,a,b)  for(__typeof(b) i=b; i>=a; i--)// [b, a]
#define     SORT(x)     sort(x.begin(), x.end());
#define     CLEAR(t)    memset((t), 0, sizeof(t));
#define     ALL(x)      (x).begin() , (x).end()

#define		sz  	    size()
#define		pb 		    push_back
#define 	pf 		    push_front

#define 	VI 		    vector<int>
#define		VS 		    vector<string>
#define     VC          vector<char>
#define 	LL 		    long long
#define 	VL 		    vector<LL>
#define 	PII 	    pair<int, int>
#define 	PLL 	    pair<LL, LL>
#define 	VII 	    vector<PII>
#define 	VLL 	    vector<PLL>
#define 	VVI 	    vector< VI >
#define 	VVL 	    vector< VL >
#define		MII 	    map<int, int>
#define 	MLL 	    map<LL, LL>
#define 	MLS 	    map<LL, string>
#define 	MSL 	    map<string, LL>
#define 	MIS 	    map<int, string>
#define		MSI 	    map<string, int>
#define 	MSS 	    map<string, string>

const 	    LL          INF = (1<<30);
const	    double      eps = (1e-11);
const 	    LL          MOD = (LL)(1e9+7);
const 	    double      PI  = (acos(-1.0));
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

//easy functions
template< typename T >
inline T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
inline T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
inline bool is_lower(char x) { return ('a' <= x && x <= 'z'); }
inline bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
inline bool is_digit(char x) { return ('0' <= x && x <= '9'); }
//______________________________________________________________

bool compa(PLL & a, PLL & b){
    if(a.second == b.second)return a.first < b.first;
    return a.second > b.second;
}

int main(){

    FAST_IO;

    //type your codes here..........
    LL n;cin>>n;

    VLL va;
    REP(i,n){
        LL a, b, c, d;
        cin>>a>>b>>c>>d;
        vau.pb({i+1, a+b+c+d});///id sum
    }

    sort(ALL(vau), compa);

    int indx ;

    REP(i, n){
        if(vau[i].first == 1){
            indx = i+1;
            break;
        }
    }
    cout<<indx<<endl;

    return 0;
}


//#include "HEADERS.h"
//sleepy 's trend
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define     TCOUNT         printf("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
#define     FAST_IO 	ios_base::sync_with_stdio(false); cin.tie(0);
#define     READ        freopen("input.txt", "r", stdin);
#define     WRITE       freopen("output.txt", "w", stdout);

#define     str_to_int(stroka)      atoi(stroka.c_str())
#define     str_to_ll(stroka)       atoll(stroka.c_str())
#define     str_to_double(stroka)   atof(stroka.c_str()

#define 	REP(i,n)    for(__typeof(n) i=0; i<n; i++)// [0, n)
#define 	FOR(i,a,b)  for(__typeof(b) i=a; i<=b; i++)// [a, b]
#define 	ROF(i,a,b)  for(__typeof(b) i=b; i>=a; i--)// [b, a]
#define     SORT(x)     sort(x.begin(), x.end());
#define     CLEAR(t)    memset((t), 0, sizeof(t));
#define     ALL(x)      (x).begin() , (x).end()

#define		sz  	    size()
#define		pb 		    push_back
#define 	pf 		    push_front

#define 	VI 		    vector<int>
#define		VS 		    vector<string>
#define     VC          vector<char>
#define 	LL 		    long long
#define 	VL 		    vector<LL>
#define 	PII 	    pair<int, int>
#define 	PLL 	    pair<LL, LL>
#define 	VII 	    vector<PII>
#define 	VLL 	    vector<PLL>
#define 	VVI 	    vector< VI >
#define 	VVL 	    vector< VL >
#define		MII 	    map<int, int>
#define 	MLL 	    map<LL, LL>
#define 	MLS 	    map<LL, string>
#define 	MSL 	    map<string, LL>
#define 	MIS 	    map<int, string>
#define		MSI 	    map<string, int>
#define 	MSS 	    map<string, string>

const 	    LL          INF = (1<<30);
const	    double      eps = (1e-11);
const 	    LL          MOD = (LL)(1e9+7);
const 	    double      PI  = (acos(-1.0));
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

//easy functions
template< typename T >
inline T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
inline T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
inline bool is_lower(char x) { return ('a' <= x && x <= 'z'); }
inline bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
inline bool is_digit(char x) { return ('0' <= x && x <= '9'); }
//______________________________________________________________

bool compa(PLL  a, PLL  b){
    if(a.second == b.second)return a.first < b.first;
    else return a.second > b.second;
}

int main(){

    FAST_IO;

    //type your codes here..........
    LL n;cin>>n;

    VLL vau;
    REP(i,n){
        LL a, b, c, d;
        cin>>a>>b>>c>>d;
        vau.pb({i+1, a+b+c+d});///id sum
    }

    sort(vau.begin(), vau.end(), compa);

    LL indx ;

    REP(i, n){
        if(vau[i].first == 1){
            indx = i+1;

        }
    }
    cout<<indx<<endl;

    return 0;
}


//#include "HEADERS.h"
//sleepy 's trend
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define     TCOUNT         printf("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
#define     FAST_IO 	ios_base::sync_with_stdio(false); cin.tie(0);
#define     READ        freopen("input.txt", "r", stdin);
#define     WRITE       freopen("output.txt", "w", stdout);

#define     str_to_int(stroka)      atoi(stroka.c_str())
#define     str_to_ll(stroka)       atoll(stroka.c_str())
#define     str_to_double(stroka)   atof(stroka.c_str()

#define 	REP(i,n)    for(__typeof(n) i=0; i<n; i++)// [0, n)
#define 	FOR(i,a,b)  for(__typeof(b) i=a; i<=b; i++)// [a, b]
#define 	ROF(i,a,b)  for(__typeof(b) i=b; i>=a; i--)// [b, a]
#define     SORT(x)     sort(x.begin(), x.end());
#define     CLEAR(t)    memset((t), 0, sizeof(t));
#define     ALL(x)      (x).begin() , (x).end()

#define		sz  	    size()
#define		pb 		    push_back
#define 	pf 		    push_front

#define 	VI 		    vector<int>
#define		VS 		    vector<string>
#define     VC          vector<char>
#define 	LL 		    long long
#define 	VL 		    vector<LL>
#define 	PII 	    pair<int, int>
#define 	PLL 	    pair<LL, LL>
#define 	VII 	    vector<PII>
#define 	VLL 	    vector<PLL>
#define 	VVI 	    vector< VI >
#define 	VVL 	    vector< VL >
#define		MII 	    map<int, int>
#define 	MLL 	    map<LL, LL>
#define 	MLS 	    map<LL, string>
#define 	MSL 	    map<string, LL>
#define 	MIS 	    map<int, string>
#define		MSI 	    map<string, int>
#define 	MSS 	    map<string, string>

const 	    LL          INF = (1<<30);
const	    double      eps = (1e-11);
const 	    LL          MOD = (LL)(1e9+7);
const 	    double      PI  = (acos(-1.0));
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

//easy functions
template< typename T >
inline T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
inline T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
inline bool is_lower(char x) { return ('a' <= x && x <= 'z'); }
inline bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
inline bool is_digit(char x) { return ('0' <= x && x <= '9'); }
//______________________________________________________________

bool compa(PLL & a, PLL & b){
    if(a.second == b.second)return a.first < b.first;
    else return a.second > b.second;
}

int main(){

    FAST_IO;

    //type your codes here..........
    LL n;cin>>n;

    VLL vau(n);
    REP(i,n){
        LL a, b, c, d;
        cin>>a>>b>>c>>d;
        vau.pb({i+1, a+b+c+d});///id sum
    }

    sort(vau.begin(), vau.end(), compa);

    LL indx ;

    REP(i, n){
        if(vau[i].first == 1){
            indx = i+1;

        }
    }
    cout<<indx<<endl;

    return 0;
}


//#include "HEADERS.h"
//sleepy 's trend
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define     TCOUNT         printf("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
#define     FAST_IO 	ios_base::sync_with_stdio(false); cin.tie(0);
#define     READ        freopen("input.txt", "r", stdin);
#define     WRITE       freopen("output.txt", "w", stdout);

#define     str_to_int(stroka)      atoi(stroka.c_str())
#define     str_to_ll(stroka)       atoll(stroka.c_str())
#define     str_to_double(stroka)   atof(stroka.c_str()

#define 	REP(i,n)    for(__typeof(n) i=0; i<n; i++)// [0, n)
#define 	FOR(i,a,b)  for(__typeof(b) i=a; i<=b; i++)// [a, b]
#define 	ROF(i,a,b)  for(__typeof(b) i=b; i>=a; i--)// [b, a]
#define     SORT(x)     sort(x.begin(), x.end());
#define     CLEAR(t)    memset((t), 0, sizeof(t));
#define     ALL(x)      (x).begin() , (x).end()

#define		sz  	    size()
#define		pb 		    push_back
#define 	pf 		    push_front

#define 	VI 		    vector<int>
#define		VS 		    vector<string>
#define     VC          vector<char>
#define 	LL 		    long long
#define 	VL 		    vector<LL>
#define 	PII 	    pair<int, int>
#define 	PLL 	    pair<LL, LL>
#define 	VII 	    vector<PII>
#define 	VLL 	    vector<PLL>
#define 	VVI 	    vector< VI >
#define 	VVL 	    vector< VL >
#define		MII 	    map<int, int>
#define 	MLL 	    map<LL, LL>
#define 	MLS 	    map<LL, string>
#define 	MSL 	    map<string, LL>
#define 	MIS 	    map<int, string>
#define		MSI 	    map<string, int>
#define 	MSS 	    map<string, string>

const 	    LL          INF = (1<<30);
const	    double      eps = (1e-11);
const 	    LL          MOD = (LL)(1e9+7);
const 	    double      PI  = (acos(-1.0));
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

//easy functions
template< typename T >
inline T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
inline T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
inline bool is_lower(char x) { return ('a' <= x && x <= 'z'); }
inline bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
inline bool is_digit(char x) { return ('0' <= x && x <= '9'); }
//______________________________________________________________

bool compa(PLL & a, PLL & b){
    if(a.second == b.second)return a.first < b.first;
    return a.second > b.second;
}

int main(){

    FAST_IO;

    //type your codes here..........
    LL n;cin>>n;

    VLL vau
    REP(i,n){
        LL a, b, c, d;
        cin>>a>>b>>c>>d;
        vau.pb({i+1, a+b+c+d});///id sum
    }

    sort(ALL(vau), compa);

    int indx ;

    REP(i, n){
        if(vau[i].first == 1){
            indx = i+1;
            break;
        }
    }
    cout<<indx<<endl;

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {

     int arr[1000][4];

     int n{}; cin>>n;

     for(int i{};i<n;i++)
     {
         for(int j{};j<4;j++)
         {
             cin>>arr[i][j];
         }
     }

    for(int i{};i<n;i++)
    {
        for(int j{};j<3;j++)
        {
            *arr[i] = *arr[i] + arr[i][j+1] ;
        }

    }

    int tom {*arr[0]};
    bool will{true};

    while (true)
    {
        bool vis{true};
        for(int i{1};i<n;i++)
        {

                if (*arr[i-1] < *arr[i])
                {
                    int temp{};
                    temp = *arr[i];
                    *arr[i] = * arr[i-1];
                    *arr[i-1] = temp;
                    vis = false;
                }
        }

        for(int i{};i<n;i++)
        {
            if (*arr[i] == tom)
            {
                if(will)
                {
                    tom = i ;
                    will = false;
                }
            }
        }

        if(vis) break;
    }

    cout<<tom+1<<endl;

}


#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n{},m{};

    cin>>n;

    int**x = new int *[n+1]{};

    for(size_t i{}; i < n ; i++)
    {
        x[i] = new int [4]{};
        for(size_t j{};j<4;j++)
        {
            cin>>x[i][j];
        }
    }
    size_t rank{},sum{},tr{1};
    for(size_t i{}; i < n ; i++)
    {
        for(size_t j{};j<4;j++)
        {
            if((j+1)==4) break;
           *x[i] +=x[i][j];
        }
        if(tr)
        {

            sum = *x[i];
            rank=i;
            tr=0;
        }
        if(sum < *x[i])
        {
            sum =*x[i];
            rank=i;
        }
    }
    cout<<rank+1<<endl;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {

     int arr[1000][4];

     int count{};

     int n{}; cin>>n;

     for(int i{};i<n;i++)
     {
         for(int j{};j<4;j++)
         {
             cin>>arr[i][j];
         }

     }

    for(int i{};i<n;i++)
    {
        for(int j{};j<3;j++)
        {

            *arr[i] = *arr[i] + arr[i][j+1] ;
        }

    }

    int tom {*arr[0]};
    bool will{true};

    while (true)
    {
        bool vis{true};
        for(int i{1};i<n;i++)
        {
        count++;

                if (*arr[i-1] < *arr[i])
                {
                    int temp{};
                    temp = *arr[i];
                    *arr[i] = * arr[i-1];
                    *arr[i-1] = temp;
                    vis = false;

                  //  cout<<"arr n  "<<*arr[i] << "  i " <<i<<endl;
                }

        }

        if(vis) break;
    }

    for(int i{};i<n;i++)
    {
        if (*arr[i] == tom)
        {
            if(will)
            {
                tom = i ;
                will = false;
            }
        }
    }

    cout<<tom+1<<endl;

}


#include <iostream>
#include <vector>

using namespace std;

int main() {

     int arr[1000][4];

     int n{}; cin>>n;

     for(int i{};i<n;i++)
     {
         for(int j{};j<4;j++)
         {
             cin>>arr[i][j];
         }
     }

    for(int i{};i<n;i++)
    {
        for(int j{};j<3;j++)
        {
            *arr[i] = *arr[i] + arr[i][j+1] ;
        }

    }

    int tom {*arr[0]};
    bool will{true};

    while (true)
    {
        bool vis{true};
        for(int i{};i<n;i++)
        {

                if (*arr[i] < *arr[i+1])
                {
                    int temp{};
                    temp = *arr[i+1];
                    *arr[i+1] = * arr[i];
                    *arr[i] = temp;
                    vis = false;
                }
        }

        for(int i{};i<n;i++)
        {
            if (*arr[i] == tom)
            {
                if(will)
                {
                    tom = i ;
                    will = false;
                }
            }
        }

        if(vis) break;
    }

    cout<<tom+1<<endl;

}


#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n{},m{};

    cin>>n;

    int**x = new int *[n]{};

    for(size_t i{}; i < n ; i++)
    {
        x[i] = new int [4]{};
        for(size_t j{};j<4;j++)
        {
            cin>>x[i][j];
        }
    }
    size_t rank{},sum{},tr{1};
    for(size_t i{}; i < n ; i++)
    {
        for(size_t j{};j<4;j++)
        {
            if((j+1)==4) break;
           *x[i] +=x[i][j];
        }
        if(tr)
        {

            sum = *x[i];
            rank=i;
            tr=0;
        }
        if(sum < *x[i])
        {
            sum =*x[i];
            rank=i;
        }
    }
    cout<<rank+1<<endl;
}


#include<bits/stdc++.h>
using  namespace std;
int  main()
{
   int n,i,j;
   cin>>n;
   int m=-1;
   int c;
   int a[1005][4];
   vector<int>v;
   int marks;
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=4;j++)
       {
           cin>>a[i][j];
       }
   }
   for(int i=1;i<=n;i++)
   {
       marks=0;
       for(int j=1;j<=4;j++)
       {
           marks=marks+a[i][j];
       }
       v.push_back(marks);
   }
  int temp=v[0];
  int count=1;
  for(int i=1;i<v.size();i++)
  {
      if(temp<v[i])
      {
          count=i;
      }
  }
  cout<<count;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int m1,m2,m3,m4;
    cin>>m1>>m2>>m3>>m4;
    int sum1=m1+m2+m4+m3;
    int ans=1;
    n--;
    while(n--)
    {
        int m1,m2,m3,m4;
        cin>>m1>>m2>>m3>>m4;
        if(sum1<m1+m2+m3+m4)
        {
            ans++;
        }

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


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin >> n;
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   int thomas=a+b+c+d;
   int id=1;
   n=n-1;
   while(n--)
   {
       cin >> a >> b >> c >>d;
       int sum=a+b+c+d;
       if(sum > thomas)
       {
           id++;
       }
   }
   cout<< id;

    return 0;
}


#include<bits/stdc++.h>
using  namespace std;
int  main()
{
    int n,k,i;
    cin>>n;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int th=a+b+c+d;
    int ans=1;
    for(i=2;i<=n;i++)
    {
        cin>>a>>b>>c>>d;
        if(a+b+c+d>th)
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;

}


#include<bits/stdc++.h>
using  namespace std;
int  main()
{
   int n,i,j;
   cin>>n;
   int m=-1;
   int c;
   int a[1005][4];
   int marks;
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=4;j++)
       {
           cin>>a[i][j];
       }
   }
   for(int i=1;i<=n;i++)
   {
       marks=0;
       for(int j=1;j<=4;j++)
       {
           marks=marks+a[i][j];
       }
       if(marks>m)
       {
           m=marks;
           c=i;
       }
   }

   cout<<c;

}


#include <bits/stdc++.h>
using namespace std;
#define for1(i,a,b) for(int i=a;i<=b;i++)
const int MAX=1000;

int n,tmp;
int a[MAX];
int id[MAX];

void enter()
{
    int x;
    cin>>n;
    for1(i,1,n)
    {
        a[i]=0;
        for1(j,1,4)
        {
            cin>>x;
            a[i]+=x;
        }
        id[i]=i;
    }
    tmp=1;
}

void sort1()
{
    for1(i,1,n-1)
    {
        for1(j,i+1,n)
        {
            if (a[i]<a[j])
            {
                swap(a[i],a[j]);
                swap(id[i],id[j]);
            }
        }
    }
}

void sort2()
{
    for1(i,1,n-1)
    {
        for1(j,i+1,n)
        if (a[i]==a[j])
        {
            if (id[i]>id[j])
                swap(id[i],id[j]);
        }
    }
}

void solve()
{
    sort1();
    sort2();
}

void print()
{
    for1(i,1,n)
        if (id[i]==1) cout<<i;
}

int main()
{
    enter();
    solve();
    print();
}


#include <bits/stdc++.h>
using namespace std;
#define for1(i,a,b) for(int i=a;i<=b;i++)

int n,order,a;

void enter()
{
    int x;
    cin>>n;
    a=0;
    for1(i,1,4)
    {
        cin>>x;
        a+=x;
    }
}

void solve()
{
    int tmp,x;
    order=1;
    for1(i,1,n-1)
    {
        tmp=0;
        for1(j,1,4)
        {
            cin>>x;
            tmp+=x;
        }
        if (a<tmp) order++;
    }
}

void print()
{
    cout<<order;
}

int main()
{
    enter();
    solve();
    print();
}


#include <bits/stdc++.h>
using namespace std;
#define for1(i,a,b) for(int i=a;i<=b;i++)
const int MAX=1000;

int n,tmp;
int a[MAX];

void enter()
{
    int x;
    cin>>n;
    for1(i,1,n)
    {
        a[i]=0;
        for1(j,1,4)
        {
            cin>>x;
            a[i]+=x;
        }
    }
    tmp=1;
}

void sort()
{
    for1(i,1,n-1)
    {
        for1(j,i+1,n)
            if (a[i]<a[j])
            {
                if (i==tmp) tmp=j;
                swap(a[i],a[j]);
            }
    }
}

void solve()
{
    sort();
}

void print()
{
    cout<<tmp<<endl;
}

int main()
{
    enter();
    solve();
    print();
}


#include <bits/stdc++.h>
using namespace std;
#define for1(i,a,b) for(int i=a;i<=b;i++)

int a,n,order;

void enter()
{
    int x;
    cin>>n;
    a=0;
    for1(i,1,4)
    {
        cin>>x;
        a+=x;
    }
}

void solve()
{
    int tmp,x;
    order=1;
    for1(i,1,n-1)
    {
        tmp=0;
        for1(j,1,4)
        {
            cin>>x;
            tmp+=x;
        }
        if (a<tmp) order++;
    }
}

void print()
{
    cout<<order;
}

int main()
{
    enter();
    solve();
    print();
}


#include <bits/stdc++.h>
using namespace std;
#define for1(i,a,b) for(int i=a;i<=b;i++)

int n,a,order;

void enter()
{
    int x;
    cin>>n;
    a=0;
    for1(i,1,4)
    {
        cin>>x;
        a+=x;
    }
}

void solve()
{
    int x,tmp;
    order=1;
    for1(i,1,n-1)
    {
        tmp=0;
        for1(j,1,4)
        {
            cin>>x;
            tmp+=x;
        }
        if (a<tmp) order++;
    }
}

void print()
{
    cout<<order;
}

int main()
{
    enter();
    solve();
    print();
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    int ans,b,a,c;
    vector<int> arr;
    for(int i=0;i<n;i++){
        a=0;
        for(int j=0;j<4;j++){
            cin>>b;
            a+=b;
        }
        if(i==0) c=a;
        arr.push_back(a);
    }
    sort(arr.begin(),arr.end());
    for(int i=n-1;i>=0;i-1){
        if(arr[i]==c){
            ans=n-(i+1);
            break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    int ans,b,a,c;
    vector<int> arr;
    for(int i=0;i<n;i++){
        a=0;
        for(int j=0;j<4;j++){
            cin>>b;
            a+=b;
        }
        if(i==0) c=a;
        arr.push_back(a);
    }
    sort(arr.begin(),arr.end());
    for(int i=n-1;i>=0;i--){
        if(arr[i]==c){
            ans=n-(i);
            break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    int ans,b,a,c;
    vector<int> arr;
    for(int i=0;i<n;i++){
        a=0;
        for(int j=0;j<4;j++){
            cin>>b;
            a+=b;
        }
        if(i==0) c=a;
        arr.push_back(a);
    }
    sort(arr.begin(),arr.end());
    for(int i=0;i<arr.size();i++){
        if(arr[i]==c){
            ans=i+1;
            break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    int ans,b,a,c;
    vector<int> arr;
    for(int i=0;i<n;i++){
        a=0;
        for(int j=0;j<4;j++){
            cin>>b;
            a+=b;
        }
        if(i==0) c=a;
        arr.push_back(a);
    }
    sort(arr.begin(),arr.end());
    for(int i=0;i<arr.size();i++){
        if(arr[i]==c){
            ans=i+1;
            break;
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    int ans,b,a,c;
    vector<int> arr;
    for(int i=0;i<n;i++){
        a=0;
        for(int j=0;j<4;j++){
            cin>>b;
            a+=b;
        }
        if(i==0) c=a;
        arr.push_back(a);
    }
    sort(arr.begin(),arr.end());
    for(int i=n-1;i>=0;i--){
        if(arr[i]==c){
            ans=n-(i+1);
            break;
        }
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
 int n,arrs[1007]={0},a,b,c,d,arrid[1007];
 cin>>n;
 for(int i=0;i<n;i++){
    cin>>a>>b>>c>>d;
    arrs[i]=a+b+c+d;
    arrid[i]=i+1;

 }
   int thomas=arrs[0];
   for(int i=0;i<n-1;i++){
     for(int j=0;j<n-1;j++){
        if(arrs[i]<arrs[i+1]){
            int h=arrs[i];
        arrs[i]=arrs[i+1];
        arrs[i+1]=h;
        int z=arrid[i];
        arrid[i]=arrid[i+1];
        arrid[i+1]=z;

        }
        else if(arrs[i]==arrs[i+1])
        {if (arrid[i]>arrid[i+1]){
         int h=arrs[i+1];
        arrs[i+1]=arrs[i];
        arrs[i]=h;
        int z=arrid[i];
        arrid[i]=arrid[i+1];
        arrid[i+1]=z;

        }
        }

     }
   }
   for(int i=0;i<n;i++){
    if(arrs[i]==thomas&&arrid[i]==1){
        cout<<i+1;
        break;
    }

   }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bool sortbyfrt(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.first > b.first);
}
int main()
{
 vector< pair<int ,int> > v;int n,a,b,c,d;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b>>c>>d;
  v.push_back( make_pair(a+b+c+d,i+1) );

  }

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

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

    if(v[i].second==1)
        cout<<i+1;
    break;
}

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bool sortbyfrt(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.first >= b.first);
}
int main()
{
 vector< pair<int ,int> > v;int n,a,b,c,d;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b>>c>>d;
  v.push_back( make_pair(a+b+c+d,i+1) );

  }

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

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

    if(v[i].second==1){
        cout<<i+1;
    break;}
}

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
 int n,arrs[1007]={0},a,b,c,d,arrid[1007];
 cin>>n;
 for(int i=0;i<n;i++){
    cin>>a>>b>>c>>d;
    arrs[i]=a+b+c+d;
    arrid[i]=i+1;

 }
   int thomas=arrs[0];
   for(int i=0;i<n;i++){
     for(int j=0;j<n;j++){
        if(arrs[i]<arrs[i+1]){
            int h=arrs[i];
        arrs[i]=arrs[i+1];
        arrs[i+1]=h;
        int z=arrid[i];
        arrid[i]=arrid[i+1];
        arrid[i+1]=z;

        }
        else if(arrs[i]==arrs[i+1])
        {if (arrid[i]>arrid[i+1]){
         int h=arrs[i+1];
        arrs[i+1]=arrs[i];
        arrs[i]=h;
        int z=arrid[i];
        arrid[i]=arrid[i+1];
        arrid[i+1]=z;

        }
        }

     }
   }
   for(int i=0;i<n;i++){
    if(arrs[i]==thomas&&arrid[i]==1){
        cout<<i+1;
        break;
    }

   }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bool func (pair <int ,int > a , pair <int , int > b){
if (a.first> b.first )return 1;
else if (a.first< b.first )return 0 ;
else {
if (a.second <b.second )return 1 ;
else return 0 ;
}

}
int main()
{
    pair<int , int > arr[1009];
int n , a, b,c,d;
cin >> n ;
for (int i =0 ; i <n ; i++){
    cin >> a>>b>>c>>d ;
    arr[i].first=a+b+c+d ;
    arr[i].second =i+1;
}
sort(arr, arr+n , func);

for (int i =0 ; i <n ; i++){
    if (arr[i].second==1){
        cout <<i+1;
        i=n;
    }
}

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bool func (pair <int ,int > a , pair <int , int > b){
if (a.first> b.first )return 1;
else if (a.first< b.first )return 0 ;
else {
if (a.second <b.second )return 1 ;
else return 0 ;
}

}
int main()
{
            ios_base::sync_with_stdio(0);cin.tie(0);

    pair<int , int > arr[1009];
int n , a, b,c,d;
cin >> n ;
for (int i =0 ; i <n ; i++){
    cin >> a>>b>>c>>d ;
    arr[i].first=a+b+c+d ;
    arr[i].second =i+1;
}
sort(arr, arr+n , func);

for (int i =0 ; i <n ; i++){
    if (arr[i].second==1){
        cout <<i+1;
        i=n;
    }
}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cout.precision(20);
	cout << fixed;
	int n;
	cin >> n;
	int a[n], t[n], pre[n + 1] = {0};
	for (int i = 0; i < n; i++)
		cin >> a[i], pre[i + 1] = pre[i] + a[i];
	for (int i = 0; i < n; i++)
		cin >> t[i];
	multiset<int> s;
	int sum = 0;
	int j = 0;
	for (int i = 0; i < n; i++)
	{
		s.insert(a[i] + sum);
		sum += t[i];
		int ans = 0;
		while (s.size())
		{
			if ((*s.begin()) <= sum)
			{
				ans += (*s.begin() + t[i]) - sum;
				s.erase(*s.begin());
			}
			else
			{
				break;
			}
		}
		ans += t[i] * s.size();
		cout << ans << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cout.precision(20);
	cout << fixed;
	int n;
	cin >> n;
	int a[n], t[n], pre[n + 1] = {0};
	for (int i = 0; i < n; i++)
		cin >> a[i], pre[i + 1] = pre[i] + a[i];
	for (int i = 0; i < n; i++)
		cin >> t[i];
	multiset<int> s;
	int sum = 0;
	int j = 0;
	for (int i = 0; i < n; i++)
	{
		s.insert(a[i] + sum);
		int old = sum;
		sum += t[i];
		int ans = 0;
		while (!s.empty() and *(s.begin()) <= sum)
		{
			ans += *s.begin() - old;
			s.erase(s.begin());
		}
		ans += t[i] * s.size();
		cout << ans << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cout.precision(20);
	cout << fixed;
	int n;
	cin >> n;
	int a[n], t[n], pre[n + 1] = {0};
	for (int i = 0; i < n; i++)
		cin >> a[i], pre[i + 1] = pre[i] + a[i];
	for (int i = 0; i < n; i++)
		cin >> t[i];
	multiset<int> s;
	int sum = 0;
	int j = 0;
	for (int i = 0; i < n; i++)
	{
		s.insert(a[i] + sum);
		sum += t[i];
		while (s.size())
		{
			if ((*s.begin()) <= sum)
				s.erase(*s.begin());
			else
				break;
		}
		int ans = t[i] * s.size();
		cout << ans << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cout.precision(20);
	cout << fixed;
	int n;
	cin >> n;
	int a[n], t[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> t[i];
	queue<int> q;
	for (int i = 0; i < n; i++)
	{
		int ans = min(a[i], t[i]);
		int sz = q.size();
		while (sz--)
		{
			int x = q.front();
			q.pop();
			ans += min(x, t[i]);
			if (x - t[i] > 0)
				q.push(x - t[i]);
		}
		cout << ans << " ";
		if (a[i] - t[i] > 0)
			q.push(a[i] - t[i]);
	}

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	cout.precision(20);
	cout << fixed;
	int n;
	cin >> n;
	int a[n], t[n], pre[n + 1] = {0};
	for (int i = 0; i < n; i++)
		cin >> a[i], pre[i + 1] = pre[i] + a[i];
	for (int i = 0; i < n; i++)
		cin >> t[i];
	multiset<int> s;
	int sum = 0;
	int j = 0;
	for (int i = 0; i < n; i++)
	{
		s.insert(a[i] + sum);
		int old = sum;
		sum += t[i];
		int ans = 0;
		while (s.size())
		{
			if ((*s.begin()) <= sum)
			{
				ans += (*s.begin()) - old;
				s.erase(*s.begin());
			}
			else
			{
				break;
			}
		}
		ans += t[i] * s.size();
		cout << ans << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e5+10, mod=1e9+7;

int n;
ll v[maxn], t[maxn], p[maxn], ans[maxn], f[maxn];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n;

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

	//cout << "p : ";
	for (int i=0; i<n; i++){
		cin >> t[i];
		p[i] = t[i];
		if (i > 0)
			p[i] += p[i-1];

	//	cout << p[i] << " ";
	}

	//cout << "\n";

	for (int i=0; i<n; i++){
		int l=-1, r=n;
		while (l+1 < r){
			int mid = (l+r)/2, tmp=0;
			if (i > 0)
				tmp = p[i-1];

			if (v[i] < p[mid]-tmp)
				r = mid;
			else
				l = mid;
		}

		//cout << i << ": " << r << "\n";
		//f[i] = r;
		if (r == -1)
			continue;

		f[i]++;
		f[r]--;
		ll tmp = 0;
		if (r > 0)
			tmp = p[r-1];
		if (i > 0)
			tmp -= p[i-1];

		ans[r] += v[i] - tmp;
	}

	//cout << "f: ";
	for (int i=0; i<n; i++){
		if (i > 0)
			f[i] += f[i-1];

		//cout << f[i] << " ";
		cout << ans[i] + f[i]*t[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e5+10, mod=1e9+7;

int n;
ll v[maxn], t[maxn], p[maxn], ans[maxn], f[maxn];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n;

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

	//cout << "p : ";
	for (int i=0; i<n; i++){
		cin >> t[i];
		p[i] = t[i];
		if (i > 0)
			p[i] += p[i-1];

	//	cout << p[i] << " ";
	}

	//cout << "\n";

	for (int i=0; i<n; i++){
		int l=-1, r=n;
		while (l+1 < r){
			int mid = (l+r)/2, tmp=0;
			if (i > 0)
				tmp = p[i-1];

			if (v[i] < p[mid]-tmp)
				r = mid;
			else
				l = mid;
		}

		//cout << i << ": " << r << "\n";
		//f[i] = r;
		if (r == -1)
			continue;

		f[i]++;
		f[r]--;
		ll tmp = 0;
		if (r > 0)
			tmp = p[r-1];
		if (i > 0)
			tmp -= p[i-1];

		ans[r] += v[i] - tmp;
	}

	//cout << "f: ";
	for (int i=0; i<n; i++){
		if (i > 0)
			f[i] += f[i-1];

		//cout << f[i] << " ";
		cout << ans[i] + (ll)f[i]*t[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e5+10, mod=1e9+7;

int n;
ll v[maxn], t[maxn], p[maxn], ans[maxn], f[maxn];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n;

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

	//cout << "p : ";
	for (int i=0; i<n; i++){
		cin >> t[i];
		p[i] = t[i];
		if (i > 0)
			p[i] += p[i-1];

	//	cout << p[i] << " ";
	}

	//cout << "\n";

	for (int i=0; i<n; i++){
		int l=0, r=n;
		while (l+1 < r){
			int mid = (l+r)/2, tmp=0;
			if (i > 0)
				tmp = p[i-1];

			if (v[i] < p[mid]-tmp)
				r = mid;
			else
				l = mid;
		}

		//cout << i << ": " << r << "\n";
		//f[i] = r;
		f[i]++;
		f[r]--;
		ll tmp = 0;
		if (r > 0)
			tmp = p[r-1];
		if (i > 0)
			tmp -= p[i-1];

		ans[r] += v[i] - tmp;
	}

	//cout << "f: ";
	for (int i=0; i<n; i++){
		if (i > 0)
			f[i] += f[i-1];

		//cout << f[i] << " ";
		cout << ans[i] + f[i]*t[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e6+10, mod=1e9+7;

multiset<ll> ms;
int main(){
	int n;
	cin >> n;

	ll v[n], t[n];
	for (int i=0; i<n; i++)
		cin >> v[i];
	for (int i=0; i<n; i++)
		cin >> t[i];

	ll cnt=0;
	for (int i=1; i<n; i++){
		cnt += t[i-1];
		v[i] += cnt;
	}

	cnt=0;
	for (int i=0; i<n; i++){
		ll ans=0;
		ms.insert(v[i]);
		cnt += t[i];

		vector<int> v;
		for (auto x:ms)
			if (x <= cnt){
				ans += x+t[i]-cnt;
				v.pb(x);
			}
			else
				break;

		for (auto x:v)
			ms.erase(x);

		//cout << ans << ", " << ms.size() << "\n";
		cout << ans + ms.size()*t[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e6+10, mod=1e9+7;

multiset<ll> ms;
int main(){
	int n;
	cin >> n;

	ll v[n], t[n];
	for (int i=0; i<n; i++)
		cin >> v[i];
	for (int i=0; i<n; i++)
		cin >> t[i];

	ll cnt=0;
	for (int i=1; i<n; i++){
		cnt += t[i-1];
		v[i] += cnt;
	}

	cnt=0;
	for (int i=0; i<n; i++){
		ll ans=0;
		ms.insert(v[i]);
		cnt += t[i];

		for (auto x:ms)
			if (x <= cnt){
				ans += x+t[i]-cnt;
				ms.erase(x);
			}

		//cout << ans << ", " << ms.size() << "\n";
		cout << ans + ms.size()*t[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e5+10, mod=1e9+7;

int n;
ll v[maxn], t[maxn], p[maxn], ans[maxn], f[maxn];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n;

	for (int i=1; i<=n; i++)
		cin >> v[i];

	for (int i=1; i<=n; i++){
		cin >> t[i];
		p[i] = p[i-1] + t[i];
	}

	for (int i=1; i<=n; i++){
		int l=0, r=n+1;
		while (l+1 < r){
			int mid = (l+r)/2;
			if (v[i] < p[mid]-p[i-1])
				r = mid;
			else
				l = mid;
		}

		r--;

		f[i]++;
		f[r+1]--;
		ans[r+1] += v[i]-p[r]+p[i-1];
	}

	for (int i=1; i<=n; i++){
		f[i] += f[i-1];
		cout << ans[i] + f[i]*t[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e6+10, mod=1e9+7;

multiset<ll> ms;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n;
	cin >> n;

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

	ll cnt=0;
	for (int i=0; i<n; i++){
		ll ans=0, t;
		cin >> t;

		ms.insert(v[i] + cnt);
		cnt += t;

		while (ms.size() && *ms.begin() <= cnt){
			ans += *ms.begin() + t - cnt;
			ms.erase(ms.begin());
		}

		//cout << ans << ", " << ms.size() << "\n";
		cout << ans + ms.size()*t << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e5+10, mod=1e9+7;

int n;
ll v[maxn], t[maxn], p[maxn], ans[maxn], f[maxn];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n;

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

	//cout << "p : ";
	for (int i=0; i<n; i++){
		cin >> t[i];
		p[i] = t[i];
		if (i > 0)
			p[i] += p[i-1];

	//	cout << p[i] << " ";
	}

	//cout << "\n";

	for (int i=0; i<n; i++){
		int l=-1, r=n;
		while (l+1 < r){
			int mid = (l+r)/2, tmp=0;
			if (i > 0)
				tmp = p[i-1];

			if (v[i] < p[mid]-tmp)
				r = mid;
			else
				l = mid;
		}

		//cout << i << ": " << r << "\n";
		//f[i] = r;
		f[i]++;
		f[r]--;
		ll tmp = 0;
		if (r > 0)
			tmp = p[r-1];
		if (i > 0)
			tmp -= p[i-1];

		ans[r] += v[i] - tmp;
	}

	//cout << "f: ";
	for (int i=0; i<n; i++){
		if (i > 0)
			f[i] += f[i-1];

		//cout << f[i] << " ";
		cout << ans[i] + f[i]*t[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e6+10, mod=1e9+7;

multiset<ll> ms;
int main(){
	int n;
	cin >> n;

	ll v[n], t[n];
	for (int i=0; i<n; i++)
		cin >> v[i];
	for (int i=0; i<n; i++)
		cin >> t[i];

	ll cnt=0;
	for (int i=1; i<n; i++){
		cnt += t[i-1];
		v[i] += cnt;
	}

	cnt=0;
	for (int i=0; i<n; i++){
		ll ans=0;
		ms.insert(v[i]);
		cnt += t[i];

		vector<int> v;
		for (auto x:ms)
			if (x <= cnt){
				ans += x+t[i]-cnt;
				v.pb(x);
			}

		for (auto x:v)
			ms.erase(x);

		//cout << ans << ", " << ms.size() << "\n";
		cout << ans + ms.size()*t[i] << " ";
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e6+10, mod=1e9+7;

multiset<ll> ms;
int main(){
	int n;
	cin >> n;

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

	ll cnt=0;
	for (int i=0; i<n; i++){
		ll ans=0, t;
		cin >> t;

		ms.insert(v[i] + cnt);
		cnt += t;

		while (ms.size() && *ms.begin() <= cnt){
			ans += *ms.begin() + t - cnt;
			ms.erase(ms.begin());
		}

		//cout << ans << ", " << ms.size() << "\n";
		cout << ans + ms.size()*t << " ";
	}

	return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (i + 1 - prev) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k < n and vol[k] <= temp[i]){
          D++, cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = (i + 1 - prev) * t[i] + cnt;
     }
     prev += D;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (i + 1 - prev) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k < n and vol[k] <= temp[i]){
           cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = max(0LL,  (i + 1 - prev)  * t[i] + cnt);
     }
     prev = k;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (i + 1 - prev) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k <= i and vol[k] <= temp[i]){
          D++, cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = max(0LL,  (i + 1 - prev)  * t[i] + cnt);
     }
    prev = k;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (i + 1 - prev) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k <= n and vol[k] <= temp[i]){
           cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = max(0LL,  (i + 1 - prev)  * t[i] + cnt);
     }
     prev = k;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (max(0LL, i + 1 - prev)) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k < n and vol[k] <= temp[i]){
          D++, cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = max(0LL, (max(0LL, i + 1 - prev))   * t[i] + cnt);
     }
     prev += D;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (i + 1 - prev) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k < n and vol[k] <= temp[i]){
          D++, cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = max(0LL,  (i + 1 - prev)  * t[i] + cnt);
     }
     prev += D;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  //sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (i + 1 - prev) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k <= i and vol[k] <= temp[i]){
          D++, cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = max(0LL,  (i + 1 - prev)  * t[i] + cnt);
     }
     prev += D;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (i + 1 - prev) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k < n and vol[k] <= temp[i]){
          D++, cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = max(0LL,  i + 1 - prev  * t[i] + cnt);
     }
     prev += D;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"

const int N = 2e5 + 1;

#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

signed main(){
  IOS;
  int n;
  cin >> n;
  int v[n], t[n];
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  for (int i = 0; i < n; ++i)
    cin >> t[i];

  int vol[n], temp[n];
  temp[0] = t[0];
  for (int i = 1; i < n; ++i)
    temp[i] = temp[i - 1] + t[i];

 /* for (int i = 0; i < n; ++i)
    cout << temp[i] << " ";
  cout << endl;*/

  vol[0] = v[0];

  for (int i = 1; i < n; ++i)
    vol[i] = temp[i - 1] + v[i];

  /*for (int i = 0; i < n; ++i)
    cout << vol[i] << " ";
  cout << endl;*/

  sort(vol, vol + n);

  int ans = 0;
  int k = 0, prev = 0, D = 0, i;
  for ( i = 0; i < n and k < n; ++i){
    ans = 0;
    if (temp[i] <= vol[k])
       ans = (i + 1 - prev) * t[i];
     else
     {
      int cnt = 0;
      D = 0;
      while (k <= i and vol[k] <= temp[i]){
          D++, cnt += vol[k] - temp[i], k++;
        }
        //debug(cnt);
        ans = max(0LL,  (i + 1 - prev)  * t[i] + cnt);
     }
     prev += D;
    cout << ans << " ";
   }
   for (int j = i; j < n; j ++)
    cout << 0 << " ";
  return 0;
}


#include<bits\stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define infi INT_MAX
#define inf 1LL<<60;
using namespace std;
const int mxn=1e5+10;
int pre[mxn];
main()
{
    fast
    int tc;
    tc=100;
    while(tc--)
    {
       int i,a;
       cin>>a;
       int aa[a],bb[a];
       for(i=0;i<a;i++)
        cin>>aa[i];
       for(i=0;i<a;i++)
        cin>>bb[i];
        int tem=0,ans,x=0,b=0,t=0;
        multiset<int>s;
       for(i=1;i<=a;i++)
       {
           s.insert(aa[i-1]+pre[i-1]);
           pre[i]=pre[i-1]+bb[i-1];
           if(!s.empty() && *s.begin()<=pre[i])
           {
              x+=(*s.begin()-pre[i-1]);
              s.erase(s.begin());
           }
           cout<<x+(bb[i-1]*s.size())<<endl;
           x=0;
         //  b=aa[i-1];
       }

    }
}


#include<bits\stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define infi INT_MAX
#define inf 1LL<<60;
using namespace std;
const int mxn=1e5+10;
int pre[mxn];
main()
{
    fast
    int tc;
    tc=1;
    while(tc--)
    {
       int i,a;
       cin>>a;
       int aa[a],bb[a];
       for(i=0;i<a;i++)
        cin>>aa[i];
       for(i=0;i<a;i++)
        cin>>bb[i];
        int tem=0,ans,x=0,b=0,t=0;
        multiset<int>s;
       for(i=1;i<=a;i++)
       {
           s.insert(aa[i-1]+pre[i-1]);
           pre[i]=pre[i-1]+bb[i-1];
          // cout<<pre[i]<<endl;
           while(!s.empty() && *s.begin()<=pre[i])
           {
              x+=*s.begin()-pre[i-1];
            //  cout<<*s.begin()<<endl;
              s.erase(s.begin());
           }
           //cout<<x<<endl;
           cout<<x+(bb[i-1]*s.size())<<endl;
           x=0;
         //  b=aa[i-1];
       }

    }
}


#include<bits\stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define infi INT_MAX
#define inf 1LL<<60;
using namespace std;
const int mxn=1e5+10;
int pre[mxn];
main()
{
    fast
    int tc;
    tc=1;
    while(tc--)
    {
       int i,a;
       cin>>a;
       int aa[a],bb[a];
       for(i=0;i<a;i++)
        cin>>aa[i];
       for(i=0;i<a;i++)
        cin>>bb[i];
        int tem=0,ans,x=0,b=0,t=0;
        multiset<int>s;
       for(i=1;i<=a;i++)
       {
           s.insert(aa[i-1]+pre[i-1]);
           pre[i]=pre[i-1]+bb[i-1];
           if(!s.empty() && *s.begin()<=pre[i])
           {
              x+=(*s.begin()-pre[i-1]);
              s.erase(s.begin());
           }
           cout<<x+(bb[i-1]*s.size())<<endl;
           x=0;
         //  b=aa[i-1];
       }

    }
}


// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n;
int v[MAX_N];
int t[MAX_N];
ll tsum[MAX_N + 1]; // i日目までの熱の総和
ll psum[MAX_N];
ll sum[MAX_N];

int main() {
    fastio();

    cin >> n;
    forn(i, n) cin >> v[i];
    forn(i, n) cin >> t[i];
    forn1(i, n) {
        tsum[i] = tsum[i - 1] + t[i - 1];
    }

    forn(i, n) {
        ll x = tsum[i] + v[i];
        auto it = upper_bound(tsum, tsum + n + 1, x);
        int j = it - tsum - 1;
        psum[i]++;
        psum[j]--;
        sum[j] += v[i] - (tsum[j] - tsum[i]);
    }

    ll total = 0;
    forn(i, n) {
        total += psum[i];
        cout << total * t[i] + sum[i] << ' ';
    }
    cout << endl;

    return 0;
}


// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n;
int v[MAX_N];
int t[MAX_N];
ll tsum[MAX_N + 1]; // i日目までの熱の総和
ll psum[MAX_N + 1];
ll sum[MAX_N + 1];

int main() {
    fastio();

    cin >> n;
    forn(i, n) cin >> v[i];
    forn(i, n) cin >> t[i];
    forn1(i, n) {
        tsum[i] = tsum[i - 1] + t[i - 1];
    }

    forn(i, n) {
        ll x = tsum[i] + v[i];
        auto it = upper_bound(tsum, tsum + n + 1, x);
        int j = it - tsum - 1;
        psum[i]++;
        psum[j]--;
        sum[j] += v[i] - (tsum[j] - tsum[i]);
    }

    ll total = 0;
    forn(i, n) {
        total += psum[i];
        cout << total * t[i] + sum[i] << ' ';
    }
    cout << endl;

    return 0;
}


// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n;
int v[MAX_N];
int t[MAX_N];
int tsum[MAX_N + 1]; // i日目までの熱の総和
int psum[MAX_N];
int sum[MAX_N];

int main() {
    fastio();

    cin >> n;
    forn(i, n) cin >> v[i];
    forn(i, n) cin >> t[i];
    forn1(i, n) {
        tsum[i] = tsum[i - 1] + t[i - 1];
    }

    forn(i, n) {
        int x = v[i] + tsum[i];
        auto it = upper_bound(tsum, tsum + n + 1, x);
        int j = it - tsum - 1;
        psum[i]++;
        psum[j]--;
        sum[j] += v[i] - (tsum[j] - tsum[i]);
    }

    int total = 0;
    forn(i, n) {
        total += psum[i];
        cout << total * t[i] + sum[i] << ' ';
    }
    cout << endl;

    return 0;
}


#include <bits/stdc++.h>

	    using namespace std;

	    #define ll long long
	    #define do double
	    #define ff first
	    #define ss second
	    #define FOR(a,n) for(i=0;i<n;i++){    cin>>a[i];}
	    #define pb push_back
	    #define mp make_pair
	    #define inf LONG_LONG_MAX
	    #define mod 1000000007
	    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll d,x,y;
	void extendedEuclid(ll A, ll B)
	{
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        int temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}

	ll power(ll x,ll y, ll p)
	{
	    ll res = 1;
	    x = x % p;
	    while (y > 0)
	    {  // If y is odd, multiply x with result
	        if (y & 1)
	            res = (res*x) % p;

	        y = y>>1;
	        x = (x*x) % p;
	    }
	    return res;
	}
	ll isPrime(ll n)
	        {

	           if(n==0 || n==1)
	           return 0;
	            if (n%2 == 0)
	                return 2;

	            if(n%3==0)
	                return 3;

	            for (ll i=5; i*i<=n; i=i+6)
	            {
	                if (n%i == 0)
	                   return i;
	                if (n%(i+2) == 0)
	                   return i+2;
	            }

	            return n;
	        }

vector<ll> par(500010);
map<ll,ll> value;
void ini()
{
	for(ll i=0;i<500010;i++)
		{
			par[i]=i;

		}
}

ll root(ll x)
{
	while(par[x]!=x)
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void uni(ll x,ll y)
{
	x=root(x);
	y=root(y);
	if(value[x]<=value[y])
		par[y]=par[x];
	else
		par[x]=par[y];
}

int main()
{
		FAST;
		ll n,i,j;
		cin>>n;
		ll v[n+1],t[n+1],sum[n+1]={0};

		for(i=1;i<=n;i++)
		{
			cin>>v[i];
		}

		for(i=1;i<=n;i++)
		{
			cin>>t[i];
			sum[i]=sum[i-1]+t[i];
		}

		ll ans[100010]={0};
		vector<pair<ll,ll> > day(n+1);
		for(i=1;i<=n;i++)
		{
			ll high=n,low=i,mid;
			ll x=sum[i-1];
			while(low<high)
			{
				mid=(high + low + 1)/2;
				if(x+v[i]<sum[mid])
				{
					high=mid-1;
				}
				else
					low=mid;
				//cout<<low<<" "<<high<<" "<<mid<<endl;
			}

			day[i]=mp(i,low+1);

			ans[low+1]+=v[i]-sum[low]+sum[i-1];
		}
		map<ll,ll> fr;
		for(i=1;i<=n;i++)
		{
			//cout<<day[i].ff<<" "<<day[i].ss<<endl;
			if(day[i]!=mp((ll)0,(ll)0))
			{	fr[day[i].ff]++;
				fr[day[i].ss]--;
			}
		}
		vector<ll> z(n+1);
		for(i=1;i<=n;i++)
			{
				z[i]=z[i-1]+fr[i];
			}

		for(i=1;i<=n;i++)
			cout<<z[i]*t[i]+ans[i]<<" ";

}


#include <bits/stdc++.h>

	    using namespace std;

	    #define ll long long
	    #define do double
	    #define ff first
	    #define ss second
	    #define FOR(a,n) for(i=0;i<n;i++){    cin>>a[i];}
	    #define pb push_back
	    #define mp make_pair
	    #define inf LONG_LONG_MAX
	    #define mod 1000000007
	    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll d,x,y;
	void extendedEuclid(ll A, ll B)
	{
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        int temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}

	ll power(ll x,ll y, ll p)
	{
	    ll res = 1;
	    x = x % p;
	    while (y > 0)
	    {  // If y is odd, multiply x with result
	        if (y & 1)
	            res = (res*x) % p;

	        y = y>>1;
	        x = (x*x) % p;
	    }
	    return res;
	}
	ll isPrime(ll n)
	        {

	           if(n==0 || n==1)
	           return 0;
	            if (n%2 == 0)
	                return 2;

	            if(n%3==0)
	                return 3;

	            for (ll i=5; i*i<=n; i=i+6)
	            {
	                if (n%i == 0)
	                   return i;
	                if (n%(i+2) == 0)
	                   return i+2;
	            }

	            return n;
	        }

vector<ll> par(500010);
map<ll,ll> value;
void ini()
{
	for(ll i=0;i<500010;i++)
		{
			par[i]=i;

		}
}

ll root(ll x)
{
	while(par[x]!=x)
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void uni(ll x,ll y)
{
	x=root(x);
	y=root(y);
	if(value[x]<=value[y])
		par[y]=par[x];
	else
		par[x]=par[y];
}

int main()
{
		FAST;
		ll n,i,j;
		cin>>n;
		ll v[n+1],t[n+1],sum[n+1]={0};

		for(i=1;i<=n;i++)
		{
			cin>>v[i];
		}

		for(i=1;i<=n;i++)
		{
			cin>>t[i];
			sum[i]=sum[i-1]+t[i];
		}

		ll ans[100010]={0};
		vector<pair<ll,ll> > day(n+1);
		for(i=1;i<=n;i++)
		{
			ll high=n,low=i,mid;
			ll x=sum[i-1];
			while(low<=high)
			{
				mid=(high + low)/2;
				if(x+v[i]==sum[mid])
				{
					day[i]=mp(i,mid);
					break;
				}
				else if(x+v[i]<sum[mid])
				{
					high=mid-1;
				}
				else
					low=mid+1;
				//cout<<low<<" "<<high<<" "<<mid<<endl;
			}

			if(i<=low-1)
			day[i]=mp(i,low-1);
			else
			day[i]=mp(0,0);
			//cout<<low<<" "<<high<<" "<<mid<<endl;
			ans[low]+=v[i]-sum[low-1]+sum[i-1];
		}
		map<ll,ll> fr;
		for(i=1;i<=n;i++)
		{
			//cout<<day[i].ff<<" "<<day[i].ss<<endl;
			if(day[i]!=mp((ll)0,(ll)0))
			{	fr[day[i].ff]++;
				fr[day[i].ss+1]--;
			}
		}
		vector<ll> z(n+1);
		for(i=1;i<=n;i++)
			{
				z[i]=z[i-1]+fr[i];
			}

		for(i=1;i<=n;i++)
			cout<<z[i]*t[i]+ans[i]<<" ";

}


#include <bits/stdc++.h>

	    using namespace std;

	    #define ll long long
	    #define do double
	    #define ff first
	    #define ss second
	    #define FOR(a,n) for(i=0;i<n;i++){    cin>>a[i];}
	    #define pb push_back
	    #define mp make_pair
	    #define inf LONG_LONG_MAX
	    #define mod 1000000007
	    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll d,x,y;
	void extendedEuclid(ll A, ll B)
	{
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        int temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}

	ll power(ll x,ll y, ll p)
	{
	    ll res = 1;
	    x = x % p;
	    while (y > 0)
	    {  // If y is odd, multiply x with result
	        if (y & 1)
	            res = (res*x) % p;

	        y = y>>1;
	        x = (x*x) % p;
	    }
	    return res;
	}
	ll isPrime(ll n)
	        {

	           if(n==0 || n==1)
	           return 0;
	            if (n%2 == 0)
	                return 2;

	            if(n%3==0)
	                return 3;

	            for (ll i=5; i*i<=n; i=i+6)
	            {
	                if (n%i == 0)
	                   return i;
	                if (n%(i+2) == 0)
	                   return i+2;
	            }

	            return n;
	        }

vector<ll> par(500010);
map<ll,ll> value;
void ini()
{
	for(ll i=0;i<500010;i++)
		{
			par[i]=i;

		}
}

ll root(ll x)
{
	while(par[x]!=x)
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void uni(ll x,ll y)
{
	x=root(x);
	y=root(y);
	if(value[x]<=value[y])
		par[y]=par[x];
	else
		par[x]=par[y];
}

int main()
{
		FAST;
		ll n,i,j;
		cin>>n;
		ll v[n+1],t[n+1],sum[n+1]={0};

		for(i=1;i<=n;i++)
		{
			cin>>v[i];
		}

		for(i=1;i<=n;i++)
		{
			cin>>t[i];
			sum[i]=sum[i-1]+t[i];
		}

		ll ans[100010]={0};
		vector<ll> day(n+1);
		for(i=1;i<=n;i++)
		{
			ll high=n,low=0,mid;
			ll x=sum[i-1];
			while(low<high)
			{
				mid=(high + low + 1)/2;
				if(x+v[i]<sum[mid])
				{
					high=mid-1;
				}
				else
					low=mid;
				//cout<<low<<" "<<high<<" "<<mid<<endl;
			}
			day[i]=low;
			ans[low+1]+=v[i]-sum[low]+sum[i-1];
		}
		map<ll,ll> fr;
		for(i=1;i<=n;i++)
		{
			fr[i]++;
				fr[day[i]+1]--;

		}
		vector<ll> z(n+1);
		for(i=1;i<=n;i++)
			{
				z[i]=z[i-1]+fr[i];
			}

		for(i=1;i<=n;i++)
			cout<<z[i]*t[i]+ans[i]<<" ";

}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n,sum=0;cin>>n;
vi v(n),t(n),pref(n+1,0);
map<int,int>m;
loop(i,n)
cin>>v[i];
vi diff(n+1,0);
loop(i,n)
{
    cin>>t[i];
    pref[i+1]=pref[i]+t[i];
}
set<int>s;
loop(i,n)
{
    s.insert(v[i]+pref[i]);   //insert assuming that the pile was there from the beginning
    int ans=0;

    while(!s.empty() && *s.begin()<=pref[i+1])
    {
        ans+=(*s.begin())-pref[i];
        s.erase(s.begin());
    }
    ans+=t[i]*s.size();

    cout<<ans<<" ";
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n,sum=0;cin>>n;
vi v(n),t(n);
loop(i,n)
cin>>v[i];
loop(i,n)
cin>>t[i];
multiset<int>s;
loop(i,n)
{
    s.insert(v[i]+sum);
    int ans=0;

    while(!s.empty() && *s.begin()<=sum+t[i])
    {
        ans+=(*s.begin())-sum;
        s.erase(s.begin());
    }
    ans+=t[i]*s.size();
    sum+=t[i];
    cout<<ans<<" ";
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n,sum=0;cin>>n;
vi v(n),t(n);
loop(i,n)
cin>>v[i];
vi diff(n+1,0);
loop(i,n)
{
    cin>>t[i];
    pref[i+1]=pref[i]+t[i];
}
multiset<int>s;
loop(i,n)
{
    s.insert(v[i]+pref[i]);   //insert assuming that the pile was there from the beginning
    int ans=0;

    while(!s.empty() && *s.begin()<=pref[i+1])
    {
        ans+=(*s.begin())-pref[i];
        s.erase(s.begin());
    }
    ans+=t[i]*s.size();

    cout<<ans<<" ";
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n,sum=0;cin>>n;
vi v(n),t(n),pref(n+1,0);
map<int,int>m;
loop(i,n)
cin>>v[i];
vi diff(n+1,0);
loop(i,n)
{
    cin>>t[i];
    pref[i+1]=pref[i]+t[i];
}
set<int>s;
loop(i,n)
{
    s.insert(v[i]+pref[i]);   //insert assuming that the pile was there from the beginning
    int ans=0;

    while(*s.begin()<pref[i+1])
    {
        ans+=(*s.begin())-pref[i];
        s.erase(s.begin());
    }
    ans+=t[i]*s.size();

    cout<<ans<<" ";
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n;cin>>n;
vi v(n),t(n),pref(n+1,0);
map<int,int>m;
loop(i,n)
cin>>v[i];
vi diff(n+1,0);
loop(i,n)
{
    cin>>t[i];
    pref[i+1]=pref[i]+t[i];
}
pref.erase(pref.begin());

loop(i,n)
{
    auto it=pref.begin();
    if(v[i]==0) continue;
    if(i==0)  it=lower_bound(all(pref),v[i]);
    else  it=lower_bound(all(pref),v[i]+pref[i-1]);
    if(it==pref.end())
    {
        diff[i]+=1;
        diff[n]-=1;
    }
    else
    {
        if(*it==v[i])
        {
            int idx=it-pref.begin();
            idx++;
            diff[i]+=1;
            diff[idx]-=1;
        }
        else
        {
            int idx=it-pref.begin();
            if(it==pref.begin())
            m[idx]+=v[i];
            else
            {
                it--;
                if(i!=0)
                m[idx]+=v[i]+pref[i-1]-(*it);
                else
                m[idx]+=v[i]-(*it);
                diff[i]+=1;
                diff[idx]-=1;
            }
        }
    }

}

loop(i,n)
diff[i+1]+=diff[i];

loop(i,n)
{
    cout<<diff[i]*t[i]+m[i]<<" ";
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n,sum=0;cin>>n;
vi v(n),t(n),pref(n+1,0);
loop(i,n)
cin>>v[i];
loop(i,n)
{
    cin>>t[i];
    pref[i+1]=pref[i]+t[i];
}
multiset<int>s;
loop(i,n)
{
    s.insert(v[i]+pref[i]);   //insert assuming that the pile was there from the beginning
    int ans=0;

    while(!s.empty() && *s.begin()<=pref[i+1])
    {
        ans+=(*s.begin())-pref[i];
        s.erase(s.begin());
    }
    ans+=t[i]*s.size();

    cout<<ans<<" ";
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n;cin>>n;
vi v(n),t(n),pref(n+1,0);
map<int,int>m;
loop(i,n)
cin>>v[i];
vi diff(n+1,0);
loop(i,n)
{
    cin>>t[i];
    pref[i+1]=pref[i]+t[i];
}
pref.erase(pref.begin());

loop(i,n)
{
    auto it=pref.begin();
    if(v[i]==0) continue;
    if(i==0)  it=lower_bound(all(pref),v[i]);
    else  it=lower_bound(all(pref),v[i]+pref[i-1]);
    if(it==pref.end())
    {
        diff[i]+=1;
        diff[n]-=1;
    }
    else
    {
        if(*it==v[i])
        {
            int idx=it-pref.begin();
            idx++;
            diff[i]+=1;
            diff[idx]-=1;
        }
        else
        {
            int idx=it-pref.begin();it--;
            if(i!=0)
            m[idx]+=v[i]+pref[i-1]-(*it);
            else
            m[idx]+=v[i]-(*it);
            diff[i]+=1;
            diff[idx]-=1;
        }
    }

}

loop(i,n)
diff[i+1]+=diff[i];

loop(i,n)
{
    cout<<diff[i]*t[i]+m[i]<<" ";
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n;cin>>n;
vi v(n),t(n),pref(n+1,0);
map<int,int>m;
loop(i,n)
cin>>v[i];
vi diff(n+1,0);
loop(i,n)
{
    cin>>t[i];
    pref[i+1]=pref[i]+t[i];
}
pref.erase(pref.begin());

loop(i,n)
{   auto it=pref.begin();
    if(i==0)  it=lower_bound(all(pref),v[i]);
    else  it=lower_bound(all(pref),v[i]+pref[i-1]);
    if(it==pref.end())
    {
        diff[i]+=1;
        diff[n]-=1;
    }
    else
    {
        if(*it==v[i])
        {
            int idx=it-pref.begin();
            idx++;
            diff[i]+=1;
            diff[idx]-=1;
        }
        else
        {
            int idx=it-pref.begin();it--;
            if(i!=0)
            m[idx]+=v[i]+pref[i-1]-(*it);
            else
            m[idx]+=v[i]-(*it);
            diff[i]+=1;
            diff[idx]-=1;
        }
    }

}

loop(i,n)
diff[i+1]+=diff[i];

loop(i,n)
{
    cout<<diff[i]*t[i]+m[i]<<" ";
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n,sum=0;cin>>n;
vi v(n),t(n),pref(n+1,0);
map<int,int>m;
loop(i,n)
cin>>v[i];
vi diff(n+1,0);
loop(i,n)
cin>>t[i];
set<int>s;
loop(i,n)
{
    s.insert(v[i]+sum);
    int ans=0;

    while(*s.begin()<sum+t[i])
    {
        ans+=(*s.begin())-sum;
        s.erase(s.begin());
    }
    ans+=t[i]*s.size();
    sum+=t[i];
    cout<<ans<<" ";
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(i,a,b) for(int i=a;i<=b;i++)
#define int long long int
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
#define mp make_pair
#define sz(a) int((a).size())
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define so(v) sort(all(v))
#define sod(v) sort(allr(v))
#define mfind(c, element) (c.find(element) != c.end())
#define gfind(c, element) (find(all(c),element) != c.end())
#define gfindindex(c, element) (find(all(c),element)-c.begin())
#define vp(x) cout << #x << " --> " << x << endl;
#define cp1(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define cpp1(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define ccp1(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define bsnp np3(low,high,mid);
#define hmm1 high=mid-1;
#define lmp1 low=mid+1;
#define hmp1 high=mid+1;
#define lmm1 low=mid-1;
#define fi first
#define se second
#define np1(x) cout<<#x<<"="<<x<<'\n'
#define np2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define np3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};//comparison used for sorting set<pair<i,i>,cmp>
bool myComparison(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
//increasing ordr basedd on 2nd
};
main()
{
IOS;
int n,sum=0;cin>>n;
vi v(n),t(n);
loop(i,n)
cin>>v[i];
loop(i,n)
cin>>t[i];
multiset<int>s;
loop(i,n)
{
    s.insert(v[i]+sum);
    int ans=0;

    while(*s.begin()<sum+t[i])
    {
        ans+=(*s.begin())-sum;
        s.erase(s.begin());
    }
    ans+=t[i]*s.size();
    sum+=t[i];
    cout<<ans<<" ";
}

return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<ll> vi;
int main(){
	ios_base::sync_with_stdio(false);
	ll n;cin>>n;
	vi v(n),t(n);
	for(ll i=0;i<n;i++)
		cin>>v[i];
	for(ll i=0;i<n;i++)
		cin>>t[i];
	set<ll> s;
	ll sum=0;
	ll p=0;
	while(p<n && v[p]<t[p]){
		cout<<v[p]<<" ";
		p++;
	}
	set<ll> ::iterator itr;
	map<ll,ll> mp;
	//cout<<p<<endl;
	set<ll> s1;
	for(ll i=p;i<n;i++){
		ll sum=0;
		s.insert(v[i]);
		mp[v[i]]++;
		itr=s.begin();
		while(itr!=s.end()){
			//cout<<*itr<<" ";
			if(*itr<=t[i]){
				sum=sum+((*itr)*mp[*itr]);
				mp[*itr]=0;
			}
			else{
				sum=sum+((t[i])*mp[*itr]);
				mp[*itr-t[i]]=mp[*itr];
				mp[*itr]=0;
				s1.insert(*itr-t[i]);
				//cout<<*itr-t[i]<<" "<<mp[*itr-t[i]]<<endl;
			}
			++itr;
		}
		s.clear();
		s=s1;
		s1.clear();
		cout<<sum<<" ";
	}
	return 0;
}