#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int b[n + 1], a[n + 1];
  int a_sum = 0;
  int b_sum = 0;
  int min_capacity = 0;
  int difference = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  if (b[n] != 0) {
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i - 1; j++) {
      b_sum += b[j];
      a_sum += a[j];
    }
    difference = (b_sum - a_sum);
    if ((i != n) && (difference < a[i])) break;
    if (difference > min_capacity) min_capacity = difference;
    b_sum = 0;
    a_sum = 0;
  }
  cout << min_capacity << endl;
  return 0;
}
