#include <bits/stdc++.h>
using namespace std;
char x[100010], v[100010];
int he[100010], sum;
int main() {
  int n;
  long long c;
  cin >> n >> c;
  x[0] = 0, v[0] = 0;
  he[0] = 0;
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    cin >> x[i] >> v[i];
    he[i] = sum - x[i];
    sum += v[i];
  }
  for (int i = 0; i < n; i++) cnt = max(he[i], cnt);
  cout << cnt << endl;
  return 0;
}
