#include <array>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;
typedef long long ll;
#define int long long
const int N = 2e5 + 3;
const int M = 1e7;
const ll INF = 5e18;
array<int, 2> a[N];
namespace persistentWeightSegmentTree
{
int tot, q, rt[N], C[N];
struct node
{
int l, r, num;
ll sum;
} st[M];
void modify(int& id, int pre, int l, int r, int pos, int val)
{
id = ++tot;
st[id] = st[pre];
++st[id].num;
st[id].sum += val;
if (l == r)
return;
int mid = (l + r) / 2;
if (pos <= mid)
modify(st[id].l, st[id].l, l, mid, pos, val);
else
modify(st[id].r, st[id].r, mid + 1, r, pos, val);
}
void init(int n)
{
tot = 0;
for (int i = 1; i <= n; ++i)
C[i] = a[i][1];
sort(C + 1, C + n + 1);
q = unique(C + 1, C + n + 1) - C - 1;
for (int i = 1; i <= n; ++i)
modify(rt[i], rt[i - 1], 1, q, lower_bound(C + 1, C + q + 1, a[i][1]) - C, a[i][1]);
assert(tot < M);
}
ll query(int u, int v, int l, int r, int k)
{
if (st[v].num - st[u].num <= k)
return st[v].sum - st[u].sum;
else if (l == r)
return (st[v].sum - st[u].sum) / (ll)(st[v].num - st[u].num) * (ll)k;
int mid = (l + r) / 2, x = st[st[v].l].num - st[st[u].l].num;
ll res = query(st[u].l, st[v].l, l, mid, k);
if (x < k)
res += query(st[u].r, st[v].r, mid + 1, r, k - x);
return res;
}
ll ask(int l, int r, int k)
{
return query(rt[l - 1], rt[r], 1, q, k);
}
};
ll ans[N];
struct T {
ll v, i;
bool operator<(const T b) {
return v < b.v;
}
}b[N];
void solve()
{
int n, hash[N];
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i][1] >> a[i][0];
hash[i] = 20;
ans[i] = 1e18;
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i)
{
b[i].v = a[i][1] + a[i][0];
b[i].i = i;
}
sort(b + 1, b + 1 + n);
/* for (int i = 1; i <= n; ++i)
{
cout << b[i].v << ' ' << b[i].i << endl;
}*/
persistentWeightSegmentTree::init(n);
int l = 1, r = 1;
for (int i = 1; i <= n; i++) {
if (r > b[i].i)continue;
r = b[i].i;
for (int k = l; k <= r; ++k)
{
ll val = persistentWeightSegmentTree::ask(1, k - 1, r - 1) + b[i].v;
ans[k] = min(ans[k], val);
hash[k]--;
}
while (hash[l] <= 0)l++;
}
for (int i = 1; i <= n; ++i)
cout << ans[i] << "\n";
}
unsigned main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}