Under construction

Still being built. Things may change

Prodo's 100-Day Preparation

Time limit2sMemory limit512 MB

Summary
Given a histogram-shaped rectilinear polygon by its vertices, find the largest-area L-shaped rectilinear polygon that can be cut from it.
Level

Hard8 of 10

Topics
Array, Stack, Divide and conquer
Solved
No attempts yet

Problem

Prodo and Neo will soon mark 100 days together. Prodo could not bear the fallout if he did nothing on the 100th day, so he decided to prepare a small event for Neo. Everything is ready. All that remains is to cut paper into the word "LOVE". But Prodo rushed, and he wasted paper while cutting out 'O', 'V', and 'E'. What is left is a histogram-shaped rectilinear polygon like the one in Figure 1. Since it turned out this way, Prodo wants to cut out an 'L' as big as his love.

  • The leftover paper is a histogram-shaped rectilinear polygon whose every edge is parallel to the xx-axis or the yy-axis. Prodo wants to cut an L-shaped rectilinear polygon out of it.
  • An L-shaped rectilinear polygon is a rectilinear polygon with 4 or 6 vertices, where every edge is parallel to the xx-axis or the yy-axis.
    • A rectilinear polygon with 4 vertices is a rectangle. Cutting a small rectangle from a corner of a rectangle makes an 'L' shape.

For example, when the paper is as shown in Figure 1, Figures 2, 3, and 4 show different ways to make L-shaped rectilinear polygons. There are many other ways too.

From the leftover histogram-shaped rectilinear polygon, find the L-shaped rectilinear polygon with the largest area and help Prodo.

Input

The first line contains the number of vertices NN of the rectilinear polygon (4≤N≤5000004 \le N \le 500000). Each of the next NN lines contains the coordinates (x,y)(x, y) of a vertex as integers separated by a space (0≤x,y≤1090 \le x, y \le 10^9). The starting point of the polygon is the origin (0,0)(0, 0), and the vertices are given in clockwise order. Two consecutive vertices form one edge of the rectilinear polygon, and the xx coordinates are monotonically increasing. Only the starting point and the ending point have yy coordinate 0. No three consecutive points are collinear.

Output

Print the largest area among the L-shaped rectilinear polygons that can be cut from the given paper, on one line.

Examples1

  1. Example 1

    Input
    8
    0 0
    0 100
    100 100
    100 50
    125 50
    125 60
    150 60
    150 0
    Expected output
    12500