Under construction

Still being built. Things may change

Quadrilaterals

Time limit1.7sMemory limit512 MB

Summary
Given n points with no three collinear, find the maximum total credit from all quadrilaterals, where convex and minimum-area shapes score more.
Level

Hard9 of 10

Topics
Geometry, Sorting, Divide and conquer
Solved
No attempts yet

Problem

A quadrilateral is a polygon with exactly four distinct corners and four distinct sides, with no crossing between its sides. A quadrilateral is called convex if all the inner angles at its corners are less than 180 degrees. Otherwise it is non-convex. The illustration below shows a convex quadrilateral (left) and a non-convex quadrilateral (right).

In a test problem, you are given a set PP of nn points in the plane. No three points in PP are collinear. Your task is to find as many quadrilaterals as possible by connecting four points from PP. Each point in PP can be used any number of times, and the quadrilaterals you find may overlap each other. You earn credits for each quadrilateral based on its shape and area. Convex quadrilaterals and quadrilaterals with minimum area earn more.

Let aa be the minimum area over all quadrilaterals that can be formed by connecting four points in PP. The credits are as follows.

  • Each distinct convex quadrilateral with area exactly aa earns 4 credits.
  • Each distinct non-convex quadrilateral with area exactly aa earns 3 credits.
  • Each distinct convex quadrilateral with area strictly larger than aa earns 2 credits.
  • Each distinct non-convex quadrilateral with area strictly larger than aa earns 1 credit.

Two quadrilaterals are distinct unless their corners and sides are exactly the same. There may be two or more quadrilaterals with the minimum area aa.

Given PP, write a program that outputs the maximum total credits you can earn by finding all possible quadrilaterals from PP.

Input

The first line contains an integer nn (4≤n≤10004 \le n \le 1000), the number of points in PP. Each of the next nn lines contains two integers, the x and y coordinates of a point in PP. Each coordinate is between −109-10^{9} and 10910^{9}, inclusive. No three points in PP are collinear.

Output

Print one line containing a single integer, the maximum total credits you can earn from PP.

Examples4

  1. Example 1

    Input
    4
    0 0
    1 0
    0 1
    1 1
    
    Expected output
    4
    
  2. Example 2

    Input
    4
    0 0
    10 0
    5 10
    5 8
    
    Expected output
    5
    
  3. Example 3

    Input
    4
    0 0
    10 0
    5 10
    5 3
    
    Expected output
    7
    
  4. Example 4

    Input
    5
    0 0
    0 5
    5 0
    5 5
    4 2
    
    Expected output
    14