PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000164. Gần như tất cả các ước (Almost All Divisors)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Gần như tất cả các ước (Almost All Divisors)
Almost All Divisors
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A hidden positive integer has all its positive divisors listed. Exactly and are removed, and you receive the complete remaining list, in arbitrary order with distinct entries. Find the smallest possible integer whose divisors other than and are exactly the given values. Print -1 if no such integer exists.
Input
The first line contains , the number of provided divisors. The second line contains pairwise distinct integers .
Output
Print the minimum possible , or -1 when the list is inconsistent.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
8
8 2 12 6 4 24 16 3
Output
48
Explanation
The positive divisors of are . Removing and leaves exactly the eight provided numbers.