661. Cool Triplets

0

Medium

Given N tickets of different colors, each with an integer embossed on it, we want to determine the number of different Cool Triplets that can be formed. A Cool Triplet is a set of 3 tickets (a, b, and c) where the sum of any two numbers exceeds the number on the third ticket. It is important to note that two triplets will be considered different even if one color forming the triplet occurs at a different index.

Input Format

The first line of input contains an integer N, representing the number of tickets. The second line contains N space-separated integers, representing the numbers embossed on each ticket.

Output Format

Print the number of Cool Triplets.

Example

Input

4 2 4 2 3

Output

3

Constraints

1 <= N <= 2×103
1 <= Ai <= 103
Loading...

View Submissions

Console