AtCoder Beginner Contest 118
C
Monsters Battle Royale
AtCoder
⌀ 646
原题
← BD →
翻译中…

Problem Statement

翻译中…

There are $N$ monsters, numbered $1, 2, ..., N$.

翻译中…

Initially, the health of Monster $i$ is $A_i$.

翻译中…

Below, a monster with at least $1$ health is called alive.

翻译中…

Until there is only one alive monster, the following is repeated:

翻译中…
  • A random alive monster attacks another random alive monster.
  • As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking.
翻译中…

Find the minimum possible final health of the last monster alive.

翻译中…

Constraints

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

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 ... A_N

翻译中…

Output

翻译中…

Print the minimum possible final health of the last monster alive.

翻译中…

样例

Input #1
4
2 10 8 40
Output #1
2
When only the first monster keeps on attacking, the final health of the last monster will be $2$, which is minimum.
Input #2
4
5 13 8 1000000000
Output #2
1
Input #3
3
1000000000 1000000000 1000000000
Output #3
1000000000
题目信息
题号
abc118_c
时间限制
2 s
内存限制
1024 MB

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