301580: CF299A. Ksusha and Array

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Ksusha and Array

题意翻译

输入 $N$ 个数字,你的任务是**在这些数字中**找到一个能够整除所有这些数字的数。 **【输入格式】** 第一行输入 $N$($1 \le N \le {10}^5$),第二行输入 $N$ 个数字 $a_i$($1 \le a_i \le {10}^9$)。 **【输出格式】** 输出那个数字,若没有则输出 $-1$,若有多个,可任意输出其中一个。

题目描述

Ksusha is a beginner coder. Today she starts studying arrays. She has array $ a_{1},a_{2},...,a_{n} $ , consisting of $ n $ positive integers. Her university teacher gave her a task. Find such number in the array, that all array elements are divisible by it. Help her and find the number!

输入输出格式

输入格式


The first line contains integer $ n $ $ (1<=n<=10^{5}) $ , showing how many numbers the array has. The next line contains integers $ a_{1},a_{2},...,a_{n} $ $ (1<=a_{i}<=10^{9}) $ — the array elements.

输出格式


Print a single integer — the number from the array, such that all array elements are divisible by it. If such number doesn't exist, print -1. If there are multiple answers, you are allowed to print any of them.

输入输出样例

输入样例 #1

3
2 2 4

输出样例 #1

2

输入样例 #2

5
2 1 3 1 6

输出样例 #2

1

输入样例 #3

3
2 3 5

输出样例 #3

-1

Input

题意翻译

输入 $N$ 个数字,你的任务是**在这些数字中**找到一个能够整除所有这些数字的数。 **【输入格式】** 第一行输入 $N$($1 \le N \le {10}^5$),第二行输入 $N$ 个数字 $a_i$($1 \le a_i \le {10}^9$)。 **【输出格式】** 输出那个数字,若没有则输出 $-1$,若有多个,可任意输出其中一个。

加入题单

上一题 下一题 算法标签: