#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
const int MAXN = 200005;
long long bit[MAXN];
int n;
void update(int idx, int delta) {
for (; idx <= n; idx += idx & -idx) {
bit[idx] += delta;
}
}
long long query(int idx) {
long long sum = 0;
for (; idx > 0; idx -= idx & -idx) {
sum += bit[idx];
}
return sum;
}
// Query for range [l, r]
long long query_range(int l, int r) {
if (l > r) return 0;
return query(r) - query(l - 1);
}
struct Ant {
long long d;
int type; // 1 for '+', -1 for '-'
int pos;
int original_idx;
};
bool compareAnts(const Ant& a, const Ant& b) {
return a.d < b.d;
}
int main() {
// Fast I/O
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// Redirect file I/O
// freopen("GREETINGS.INP", "r", stdin);
// freopen("GREETINGS.OUT", "w", stdout);
cin >> n;
vector<Ant> ants(n);
vector<Ant> clockwise_ants;
vector<Ant> counter_clockwise_ants;
for (int i = 0; i < n; ++i) {
char c;
long long d_val;
cin >> c >> d_val;
ants[i].d = d_val;
ants[i].pos = i + 1;
ants[i].original_idx = i + 1;
if (c == '+') {
ants[i].type = 1;
clockwise_ants.push_back(ants[i]);
} else {
ants[i].type = -1;
counter_clockwise_ants.push_back(ants[i]);
}
}
sort(ants.begin(), ants.end(), compareAnts);
vector<long long> ans(n + 1, 0);
// Phase 1: Clockwise ants greet counter-clockwise ants
fill(bit, bit + n + 1, 0);
long long ccw_count = counter_clockwise_ants.size();
for (const auto& ant : counter_clockwise_ants) {
update(ant.pos, 1);
}
for (const auto& current_ant : ants) {
if (current_ant.type == 1) { // Clockwise
long long dist = 2 * current_ant.d;
long long laps = dist / n;
long long rem = dist % n;
long long greetings = laps * ccw_count;
int start_pos = current_ant.pos;
int end_pos = start_pos + rem;
if (end_pos > n) {
greetings += query_range(start_pos + 1, n);
greetings += query_range(1, end_pos % n);
} else {
greetings += query_range(start_pos + 1, end_pos);
}
ans[current_ant.original_idx] += greetings;
} else { // Counter-clockwise ant finishes its journey
update(current_ant.pos, -1);
ccw_count--;
}
}
// Phase 2: Counter-clockwise ants greet clockwise ants
fill(bit, bit + n + 1, 0);
long long cw_count = clockwise_ants.size();
for (const auto& ant : clockwise_ants) {
update(ant.pos, 1);
}
for (const auto& current_ant : ants) {
if (current_ant.type == -1) { // Counter-clockwise
long long dist = 2 * current_ant.d;
long long laps = dist / n;
long long rem = dist % n;
long long greetings = laps * cw_count;
int start_pos = current_ant.pos;
// Cẩn thận với modulo số âm trong C++
long long end_pos_long = (long long)start_pos - rem;
int end_pos;
if (end_pos_long <= 0) {
end_pos = (end_pos_long % n + n) % n;
if (end_pos == 0) end_pos = n; // 1-based index
} else {
end_pos = end_pos_long;
}
if (end_pos < start_pos) {
greetings += query_range(end_pos, start_pos - 1);
} else { // Wrapped around
greetings += query_range(end_pos, n);
greetings += query_range(1, start_pos - 1);
}
ans[current_ant.original_idx] += greetings;
} else { // Clockwise ant finishes its journey
update(current_ant.pos, -1);
cw_count--;
}
}
for (int i = 1; i <= n; ++i) {
cout << ans[i] << "\n";
}
return 0;
}