Under construction

Still being built. Things may change

Map

Time limit2sMemory limit256 MB

Summary
Given a rectilinear polygon on the grid, find the vertical grid line x=c where folding the map once gives the smallest possible area.
Level

Medium7 of 10

Topics
Geometry, Prefix sum, Sorting
Solved
No attempts yet

Statement

While sorting through old archives of an abandoned library at the edge of the world, Captain Zhenya Vodogrey found a pirate map that shows the way to a treasure. The map is drawn on squared paper and is in good condition.

The map is a non-degenerate polygon cut strictly along the grid lines of a very large sheet of squared paper. Every vertical and horizontal line crosses the map in at most one continuous segment.

Zhenya wants to fold the map once along a vertical line x=cx = c that lies on a grid line of the paper. He wants the area of the polygon formed after folding to be as small as possible. Choose cc to minimize it.

The left part of the picture shows the map from the statement. The right part shows folding along x=2x = 2.

Input

The first line contains nn (1≤n≤3⋅1051 \le n \le 3 \cdot 10^5), the number of vertices of the map. Each of the next nn lines contains two integers, the coordinates of a vertex, in clockwise order. The coordinates are integers, non-negative, and do not exceed 10910^9.

Output

Print a single integer, the minimum area after folding.

Examples1

  1. Example 1

    Input
    12
    2 1
    2 2
    1 2
    1 3
    2 3
    2 5
    3 5
    3 3
    4 3
    4 2
    3 2
    3 1
    
    Expected output
    5