#P10666. COUNTARI

COUNTARI

Problem Description

Given an array aa of length nn, find how many triples i,j,ki, j, k (1i<j<kn)(1 \leq i < j < k \leq n) satisfy akaj=ajaia_k - a_j = a_j - a_i.

Input Format

The first line contains an integer nn. The second line contains nn positive integers aia_i.

Output Format

Output one integer in one line, representing the required result.

10
3 5 3 6 3 4 10 4 5 2
9

Hint

Constraints: 1n1051 \leq n \leq 10^5, 1ai3×1041 \leq a_i \leq 3 \times 10^4.

Translated by ChatGPT 5