問題一覧 > 通常問題

No.2046 Ans Mod? Mod Ans!

レベル : / AI推定難易度 : 1750 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 91
作問者 : 👑 箱星 / テスター : 👑 hitonanode Shirotsume
お気に入りにしたユーザー ProblemId : 6769 / 自分の提出
問題文最終更新日: 2022-08-09 22:12:42
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 357 (順位表) の他の問題:

Story

Koboshi-san is solving competitive programming problems. One problem stated the following:

Since the answer can be very large, print the remainder when $10^9+7$ is divided by the answer.

Koboshi-san misread this as "print the remainder when the answer is divided by $10^9+7$", and so could not solve it.

Feeling sad, Koboshi-san decided to investigate the error between the correct output and Koboshi-san's output. When the answer is $X$ and the divisor is $Y$, this error is expressed as $|(X\bmod{Y})-(Y\bmod{X})|$.

Based on this, Koboshi-san created the following problem.

Problem Statement

Given pairwise distinct positive integers $A_1,A_2,\ldots,A_N$, find the value of

$$\sum_{i=1}^{N-1}\sum_{j=i+1}^N|(A_i\bmod{A_j})-(A_j\bmod{A_i})|$$

.

Here, $a\bmod{b}$ denotes the remainder when $a$ is divided by $b$.

Pay attention to the execution time limit.

Constraints

  • $2\le N\le 2\times 10^5$
  • $1\le A_i\le 2\times 10^5$
  • If $i\ne j$, then $A_i\ne A_j$
  • All inputs are integers

Input

$N$
$A_1$ $A_2$ $\ldots$ $A_N$

Output

Print the answer.

Sample

Sample 1
Input
2
3 5
Output
1

$|(3\bmod{5})-(5\bmod{3})|=|3-2|=1$.

Sample 2
Input
3
1 11 111
Output
12

Sample 3
Input
9
1 9 2 8 3 7 4 6 5
Output
83

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。