PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000093. Bộ ba chỉ số (Index Trio)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bộ ba chỉ số (Index Trio)
Index Trio
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given a sequence of positive integers , count the ordered index triples satisfying and . Indices may coincide, and different ordered triples are counted separately. Since all values are positive integers, the condition is equivalent to .
Input
The first line contains . The second line contains exactly positive integers .
Output
Print one integer: the number of valid ordered index triples.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
3
6 2 3
Output
2
Explanation
The values are . For , both and hold. These yield and ; no other triple is valid. Print 2.