#P8196. Counting Magic Triplets

    ID: 21378 Type: Default 1000ms 256MiB

Counting Magic Triplets

Counting Magic Triplets

Given a sequence of integers of length \(n\) denoted as \(a\), an ordered triple \((i, j, k)\) (with \(1 \leq i \leq j \leq k \leq n\)) is called a Magic Triplet if it satisfies the equation \(a_i + a_j = a_k\). Your task is to count the total number of Magic Triplets in the sequence.

inputFormat

The input consists of two lines. The first line contains a single integer \(n\) representing the length of the sequence. The second line contains \(n\) space-separated integers that form the sequence \(a\).

outputFormat

Output a single integer representing the total number of Magic Triplets in the sequence.

sample

3
1 2 3
2

</p>