#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int maxn = 110;
const double eps = 1e-8;
struct tree {
  int x, val;
} tr[maxn];
bool cmp(tree a, tree b) { return a.x < b.x; }
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      cin >> tr[i].x >> tr[i].val;
    }
    sort(tr, tr + n, cmp);
    int k = n;
    for (int i = 0; i < n; ++i) {
      if (tr[i].x >= 0) {
        k = i;
        break;
      }
    }
    int sum = 0;
    if (k < n - k) {
      for (int i = 0; i < min(2 * k + 1, n); ++i) {
        sum += tr[i].val;
      }
    } else {
      for (int i = max(n - 2 * (n - k) - 1, 0); i < n; ++i) {
        sum += tr[i].val;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
