#P8912. [RC-06] ijk

[RC-06] ijk

Problem Description

Given a sequence [a1,a2,a3,…,an][a_1,a_2,a_3,\dots,a_n], it is guaranteed that ∀i∈[2,n],ai≥ai−1\forall i\in [2,n], a_i\ge a_{i-1}.

Compute how many integer triples (i,j,k)(i,j,k) satisfy:

  • 1≤i,j,k≤n1\le i,j,k\le n.
  • ai×j×ak=i+aj+ka_i\times j\times a_k=i+a_j+k.

Input Format

The first line contains a positive integer nn.

The second line contains nn positive integers a1,a2,…,ana_1,a_2,\dots,a_n. It is guaranteed that ai≥ai−1a_i\ge a_{i-1}.

Output Format

Output one line with one non-negative integer, which is the answer.

5
2 3 3 4 5
3
10
1 1 2 2 3 3 4 4 5 8
25

Hint

This problem has three subtasks.

All testdata satisfy: 1≤n≤1061\le n\le 10^6, 1≤ai≤1061\le a_i\le 10^6, ai≥ai−1a_i\ge a_{i-1}.

  • Subtask 11 (55 points): n≤500n\le 500.
  • Subtask 22 (55 points): ai≤10a_i\le 10.
  • Subtask 33 (9090 points): no special constraints.

Translated by ChatGPT 5