codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

299A.md (1072B)


      1 Source: https://codeforces.com/problemset/problem/299/A
      2 
      3 A. Ksusha and Array
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Ksusha is a beginner coder. Today she starts studying arrays. She has array *a*1, *a*2, ..., *a**n*, consisting of *n* positive integers.
     22 
     23 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!
     24 
     25 Input
     26 
     27 The first line contains integer *n* (1 ≤ *n* ≤ 105), showing how many numbers the array has. The next line contains integers *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 109) — the array elements.
     28 
     29 Output
     30 
     31 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.
     32 
     33 If there are multiple answers, you are allowed to print any of them.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 3  
     41 2 2 4
     42 ```
     43 
     44 Output
     45 
     46 ```
     47 2
     48 ```
     49 
     50 Input
     51 
     52 ```
     53 5  
     54 2 1 3 1 6
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 1
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 3  
     67 2 3 5
     68 ```
     69 
     70 Output
     71 
     72 ```
     73 -1
     74 ```