#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long int n, dp[110][110], d[110];
vector<pair<long long int, long long int> > pos, neg;
vector<pair<long long int, long long int> > cur[110][110];
void so(vector<pair<long long int, long long int> > &old) {
  sort(old.begin(), old.end(),
       [](pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
         if (a.first == b.first) return a.second < b.second;
         return a.first > b.first;
       });
}
long long int loc(const vector<pair<long long int, long long int> > &a,
                  long long int v) {
  for (long long int k = 0; k < a.size(); ++k)
    if (a[k].second == v) return k;
}
long long int r(long long int i, long long int j) {
  if (~dp[i][j]) return dp[i][j];
  dp[i][j] = 0;
  if (i < pos.size()) {
    vector<pair<long long int, long long int> > old = cur[i][j];
    long long int p = loc(old, pos[i].second);
    old[p].first += d[pos[i].second];
    so(old);
    long long int af = loc(old, pos[i].second);
    long long int del = abs(af - p);
    cur[i + 1][j] = old;
    dp[i][j] = max(dp[i][j], r(i + 1, j) + del);
  }
  if (j < neg.size()) {
    vector<pair<long long int, long long int> > old = cur[i][j];
    long long int p = loc(old, neg[j].second);
    old[p].first += d[neg[j].second];
    so(old);
    long long int af = loc(old, neg[j].second);
    long long int del = abs(af - p);
    cur[i][j + 1] = old;
    dp[i][j] = max(dp[i][j], r(i, j + 1) + del);
  }
  return dp[i][j];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  memset(dp, -1, sizeof dp);
  for (long long int i = 0; i < n; i++) {
    long long int a;
    cin >> a >> d[i];
    if (d[i] < 0)
      neg.push_back({a, i});
    else
      pos.push_back({a, i});
    cur[0][0].push_back({a, i});
  }
  so(pos);
  reverse(pos.begin(), pos.end());
  so(neg);
  so(cur[0][0]);
  cout << r(0, 0) << endl;
}
