AT_abc392_g [ABC392G] Fine Triplets
Description
For integers $ A, B, C $ ( $ A < B < C $ ), if they satisfy $ B-A = C-B $ , then $ (A, B, C) $ is called a **fine triplet**.
You are given a set of $ N $ distinct positive integers $ S = \{ S_1, S_2, \dots, S_N \} $ . Find the number of fine triplets $ (A, B, C) $ with $ A, B, C \in S $ .
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ S_1 $ $ S_2 $ $ \dots $ $ S_N $
Output Format
Print the number of fine triplets as an integer.
Explanation/Hint
### Sample Explanation 1
Here, $ S = \{8,3,1,5,2\} $ . The fine triplets to be counted are the following three:
- $ (1,2,3) $
- $ (1,3,5) $
- $ (2,5,8) $
### Constraints
- All input values are integers.
- $ 1 \le N \le 10^6 $
- $ 1 \le S_i \le 10^6 $
- The elements of $ S $ are distinct.