#include using namespace std; struct house { int position, alcohol; }; house h[101000]; int n,i; int calc(int a) { long long result = 0; int i; int last_pos = h[0].position; for(i=0;i= 0 && (result <= (h[i].position - last_pos))) { result = 0; } else { result -= (long long) (h[i].position - last_pos); } result += (long long) h[i].alcohol - a; last_pos = h[i].position; } return result >= 0; } int main() { scanf("%d", &n); int r=0, l=0, t; for(i=0;i