#TP0000051. Những chiếc bánh mochi hai tầng (Various Kagamimochi)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Những chiếc bánh mochi hai tầng (Various Kagamimochi)
Various Kagamimochi
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are mochi, numbered from to . The size of mochi is . Their sizes are given in nondecreasing order.
To make a two-layer kagamimochi, choose two different mochi. Place the smaller mochi above the larger one. The arrangement is valid if the upper mochi has size at most half the size of the lower one, meaning .
Two arrangements are different if at least one chosen mochi is different, even when their sizes are equal. Count all valid arrangements.
Input
- The first line contains an integer : the number of mochi.
- The second line contains exactly integers in nondecreasing order.
Output
Print one integer: the number of choices of two distinct mochi forming a valid two-layer kagamimochi.
Subtasks
- Subtask 1 (20 points): ; for every ; .
- Subtask 2 (30 points): ; for every ; .
- Subtask 3 (50 points): ; for every ; .
Examples
Input
6
2 3 4 4 7 10
Output
8
Explanation
The mochi sizes are . The mochi of size can go above four mochi (), size above two (), and each size- mochi above the size- mochi. The total is . The two size- mochi are distinct objects.