This page is still under construction.

Parts of this page are still being built. What you see may change.

Triangles

Time limit3sMemory limit512 MB

Summary
Given n distinct points, count the triples that form a non-degenerate isosceles triangle (at least two equal sides).
Level

Medium7 of 10

Topics
Geometry, Hash map, Math, Sorting
Solved
No attempts yet

Problem

Petya has been attending a math club for quite a while, so he has already learned not only the rules for basic operations but also a rather difficult concept: symmetry. To study symmetry better, Petya decided to start with the simplest geometric figures, triangles. He soon realized that the figures with axial symmetry are the so-called isosceles triangles. So now Petya looks for such triangles everywhere.

Recall that a triangle is isosceles if its area is positive and it has at least two equal sides. Recently, when Petya walked into his classroom, he saw n points drawn on the blackboard. Naturally, he immediately wondered how many triples of these points are the vertices of isosceles triangles.

You must write a program that solves this problem.

Input

The input file contains an integer n (3 ≤ n ≤ 1500). Each of the following n lines contains two integers xi and yi, the coordinates of the i-th point. The absolute value of each coordinate does not exceed 109. No two given points coincide.

Output

Output the answer to the problem to the output file.

Examples2

  1. Example 1

    Input
    3
    0 0
    2 2
    -2 2
    
    Expected output
    1
    
  2. Example 2

    Input
    4
    0 0
    1 1
    1 0
    0 1
    
    Expected output
    4