#4592. abc388c镜饼

abc388c镜饼

Problem Statement

There are NN mochi (rice cakes) arranged in ascending order of size. The size of the ii-th mochi (1iN)(1 \leq i \leq N) is AiA_i.

Given two mochi AA and BB, with sizes aa and bb respectively, you can make one kagamimochi (a stacked rice cake) by placing mochi AA on top of mochi BB if and only if aa is at most half of bb.

You choose two mochi out of the NN mochi, and place one on top of the other to form one kagamimochi.

Find how many different kinds of kagamimochi can be made.

Two kagamimochi are distinguished if at least one of the mochi is different, even if the sizes of the mochi are the same.

Constraints

  • 2N5×1052 \leq N \leq 5 \times 10^5
  • 1Ai109 (1iN)1 \leq A_i \leq 10^9 \ (1 \leq i \leq N)
  • AiAi+1 (1i<N)A_i \leq A_{i+1} \ (1 \leq i \lt N)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN A1A_1 A2A_2 \cdots ANA_N

Sample Input 1

6
2 3 4 4 7 10

Sample Output 1

8

The sizes of the given mochi are as follows:

In this case, you can make the following eight kinds of kagamimochi:

Note that there are two kinds of kagamimochi where a mochi of size 44 is topped by a mochi of size 22, and two kinds where a mochi of size 1010 is topped by a mochi of size 44.

Sample Input 2

3
387 388 389

Sample Output 2

0

It is possible that you cannot make any kagamimochi.

Sample Input 3

32
1 2 4 5 8 10 12 16 19 25 33 40 50 64 87 101 149 175 202 211 278 314 355 405 412 420 442 481 512 582 600 641

Sample Output 3

388
}