AtCoder Regular Contest 147
A
Max Mod Min
AtCoder
⌀ 347
原题
←B →
翻译中…

Problem Statement

翻译中…

You are given a sequence of $N$ positive integers: $A=(A_1,A_2,\dots,A_N)$.

翻译中…

You will repeat the following operation until the length of $A$ becomes $1$.

翻译中…
  • Let $k$ be the length of $A$ before this operation. Choose integers $i$ and $j$ such that $\max(\{A_1,A_2,\dots,A_{k}\})=A_i,\min(\{A_1,A_2,\dots,A_{k}\})=A_j$, and $i \neq j$. Then, replace $A_i$ with $(A_i \bmod A_j)$. If $A_i$ becomes $0$ at this moment, delete $A_i$ from $A$.
翻译中…

Find the number of operations that you will perform. We can prove that, no matter how you choose $i,j$ in the operations, the total number of operations does not change.

翻译中…

Constraints

翻译中…
  • $2 \le N \le 2 \times 10^5$
  • $1 \le A_i \le 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \dots A_N

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
3
2 3 6
Output #1
3
You will perform $3$ operations as follows: - Choose $i=3,j=1$. You get $A_3=0$, and delete $A_3$ from $A$. Now you have $A=(2,3)$. - Choose $i=2,j=1$. You get $A_2=1$. Now you have $A=(2,1)$. - Choose $i=1,j=2$. You get $A_1=0$, and delete $A_1$ from $A$. Now you have $A=(1)$, and terminate the process because the length of $A$ becomes $1$.
Input #2
6
1232 452 23491 34099 57341 21488
Output #2
12
题目信息
题号
arc147_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。