// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <numeric>

#define ll long long int
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define drep(i, n) for(ll i = ((ll)(n) - 1); i >= 0; i--)
#define frep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); i++)
#define vall(v) (v).begin(),(v).end()
#define mod 1000000007
#define inf 9223372036854775800

using namespace std;

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
int main() {

    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }

    ll ans = 0;
    ll x = 0;
    map<ll,ll> s;
    s[0] = 1;
    rep(i,n){
        if(i % 2 == 0){
            x += a[i];
        }else{
            x -= a[i];
        }
        if(s.count(x)){
            ans += s[x];
            s[x]++;
            // cout << i << " " << x << endl;
        }else{
            s[x] = 1;
        }
    }

    cout << ans << endl;

    return 0;
}
//////////////////////////////////////////////////





#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define N 200100
#define MOD 1000000007  //998244353
#define ll long long
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define rep3(i, a, b) for(int i = a; i >= b; --i)
#define eb emplace_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
struct Setup_io {
	Setup_io() {
		ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
		cout << fixed << setprecision(15);
	}
} setup_io;



int main() {
	int n;
	ll a[N];
	ll b[N];
	ll c[N];
	ll x = 0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		x = max(x, a[i]);
		if (i == 0)c[0] = a[0] * b[0];
		else c[i] = max(c[i - 1], x*b[i]);
	}
	rep(i, n) {
		cout << c[i]<<endl;
	}
	return 0;
}
