#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
struct sColorBall
{
int n, color, size;
sColorBall() = default;
sColorBall(int n, int color, int size):n(n),color(color),size(size)
{
}
};
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin >> n;
vector<sColorBall> vecBall(n);
for (int i = 0; i < n; i++)
{
vecBall[i].n = i;
cin >> vecBall[i].color >> vecBall[i].size;
}
sort(vecBall.begin(), vecBall.end(), [](const sColorBall& a, const sColorBall& b) -> bool
{
return a.size < b.size;
});
map<int, int> mapBalls;
vector<int> res(n);
int j = 0, sum = 0;
for (int i = 0; i < n; i++)
{
for (; j < n; j++)
{
auto a = vecBall[i], b = vecBall[j];
if (a.size > b.size)
{
sum += b.size;
mapBalls[b.color] += b.size;
}
else if (a.size == b.size)
break;
}
auto a = vecBall[i];
res[a.n] = sum - mapBalls[a.color];
}
for (auto r : res)
{
cout << r << '\n';
}
return 0;
}