- Practice
- Data Structures
- Advanced
- Triplets

# Triplets

# Triplets

There is an integer array which does not contain more than two elements of the same value. How many distinct ascending triples () are present?

**Input format**

The first line contains an integer, , denoting the number of elements in the array. This is followed by a single line, containing space-separated integers. Please note that there are no leading spaces before the first number, and there are no trailing spaces after the last number.

**Output format:**

A single integer that denotes the number of distinct ascending triplets present in the array.

**Constraints:**

^{}

Every element of the array is present at most twice.

Every element of the array is a 32-bit non-negative integer.

**Sample input:**

```
6
1 1 2 2 3 4
```

**Sample output:**

```
4
```

**Explanation**

The distinct triplets are

(1,2,3)

(1,2,4)

(1,3,4)

(2,3,4)

The elements of the array might not be sorted. Make no assumptions of the same.