Largest Region in a Rectilinear Polygon

Time limit1sMemory limit128 MB

Problem

In the two-dimensional plane, a rectilinear polygon is a polygon whose every side is horizontal or vertical. A general rectilinear polygon may have sides that intersect each other, while a simple rectilinear polygon has no intersecting sides.

This problem considers only general rectilinear polygons satisfying all of the following conditions.

  1. No two vertices are at the same point.
  2. At each vertex, exactly one horizontal side and exactly one vertical side meet at that endpoint.
  3. Whenever sides intersect, the intersection is between a horizontal side and a vertical side. Two horizontal sides never intersect each other, and two vertical sides never intersect each other.

Such a general rectilinear polygon partitions the plane, excluding the exterior, into several simple rectilinear polygonal regions. Given the general rectilinear polygon, compute the largest area among those simple rectilinear regions.

Input

The first line contains an integer N, the number of vertices of the general rectilinear polygon. (4 <= N <= 1,000)

Each of the next N lines contains two integers x and y, the coordinates of one vertex. (0 <= x, y <= 10,000)

Connecting each pair of consecutive vertices in input order, and then connecting the last vertex to the first vertex, forms the general rectilinear polygon.

Output

Print one integer: the largest area among the simple rectilinear regions formed by the given general rectilinear polygon.

Note

The original title of this problem is "Area of a Rectilinear Polygon".