#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,a,b) for(int i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 5;
int n;
int a[maxn], b[maxn], lg[maxn], st[maxn][22];
void init() {
	fo(i, 1, n)st[i][0] = a[i];
	fo(i, 2, n)lg[i] = lg[i >> 1] + 1;
	for (int j = 1; j <= lg[n]; ++j) {
		for (int i = 1; i + (1 << j) - 1 <= n; ++i) {
			st[i][j] = max(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);
		}
	}
}
int f(int l, int r) {
	int k = lg[r - l + 1];
	return max(st[l][k], st[r - (1 << k) + 1][k]);
}
int main() {
	IOS;
	cin >> n;
	fo(i, 1, n)cin >> a[i];
	fo(i, 1, n)cin >> b[i];
	init();
	ll ans = 0;
	fo(i, 1, n) {
		ans = max(ans, 1ll * f(1, i) * b[i]);
		cout << ans << endl;
	}

	return 0;
}
/*

*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define int long long
#define ld long double
#define vint vector<int>
#define vpair vector<pair<int, int>>
#define vvec vector<vector<int>>
#define vvpair vector<vector<pair<int, int>>>
#define qint queue<int>
#define pint pair<int, int>
#define ps(x,y) fixed<<setprecision(y)<<x
#define all(x) x.begin(), x.end()
#define revall(x) x.rbegin(), x.rend()
#define in(v, s, e) for(int i = s; i<e; i++){cin >> v[i];}
#define out(v, s, e) for(int i = s; i<e; i++){cout << v[i];}

const int mod = 1e9 + 7;
const int MAX = 1e18;


int sol(int n)
{
    int ans = 1;

    while(n > 0)
    {
        ans *= 10;
        n--;
    }

    return ans;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    int ans = 0;
    int x = log10(n);
    while(x >= 3)
    {
        // cout << n << " " << x << endl;
        int y = sol(x);
        // cout << y << endl;
        ans += (n - y + 1)*(x/3);
        // cout << y << " " << x << " " << ans << endl;
        n = y;
        n--;
        x--;
    }

    cout << ans;
}