atcoder#RELAY2F. Capture

Capture

Score : 100100 points

Problem Statement

In a long narrow forest stretching east-west, there are NN beasts. Below, we will call the point that is pp meters from the west end Point pp. The ii-th beast from the west (1iN)(1 \leq i \leq N) is at Point xix_i, and can be sold for sis_i yen (the currency of Japan) if captured.

You will choose two integers LL and RR (LR)(L \leq R), and throw a net to cover the range from Point LL to Point RR including both ends, [L,R][L, R]. Then, all the beasts in the range will be captured. However, the net costs RLR - L yen and your profit will be ((the sum of sis_i over all captured beasts i)(RL)i) - (R - L) yen.

What is the maximum profit that can be earned by throwing a net only once?

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 1x1<x2<...<xN10151 \leq x_1 < x_2 < ... < x_N \leq 10^{15}
  • 1si1091 \leq s_i \leq 10^9
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

NN

x1x_1 s1s_1

x2x_2 s2s_2

::

xNx_N sNs_N

Output

When the maximum profit is XX yen, print the value of XX.

5
10 20
40 50
60 30
70 40
90 10
90

If you throw a net covering the range [L=40,R=70][L = 40, R = 70], the second, third and fourth beasts from the west will be captured, generating the profit of s2+s3+s4(RL)=90s_2 + s_3 + s_4 - (R - L) = 90 yen. It is not possible to earn 9191 yen or more.

5
10 2
40 5
60 3
70 4
90 1
5

The positions of the beasts are the same as Sample 1, but the selling prices dropped significantly, so you should not aim for two or more beasts. By throwing a net covering the range [L=40,R=40][L = 40, R = 40], you can earn s2(RL)=5s_2 - (R - L) = 5 yen, and this is the maximum possible profit.

4
1 100
3 200
999999999999999 150
1000000000000000 150
299