PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000217. Tổng thương phần nguyên của cặp cực đại/cực tiểu (Max/Min)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tổng thương phần nguyên của cặp cực đại/cực tiểu (Max/Min)

Tổng thương phần nguyên của cặp cực đại/cực tiểu (Max/Min)

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given NN positive integers A1,…,ANA_1,\ldots,A_N, compute

$$\sum_{1\le i<j\le N}\left\lfloor\frac{\max(A_i,A_j)}{\min(A_i,A_j)}\right\rfloor.$$

Count each pair of distinct indices exactly once, including equal values.

Input

The first line contains NN; the second line contains NN integers AiA_i.

Output

Print the sum as a 64-bit integer.

Subtasks

  • Subtask 1 (20 points): 2≤N≤502\le N\le 50; 1≤Ai≤1001\le A_i\le 100.

  • Subtask 2 (30 points): 2≤N≤50002\le N\le 5000; 1≤Ai≤200001\le A_i\le 20000.

  • Subtask 3 (50 points): 2≤N≤2000002\le N\le 200000; 1≤Ai≤10000001\le A_i\le 1000000.

Examples

Example 1

Input

3
3 1 4

Output

8

Explanation

The three pair contributions are 3, 1, and 4.

Example 2

Input

6
2 7 1 8 2 8

Output

53

Explanation

Equal-valued pairs count separately by index.