PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000082. Làm phẳng dãy bằng bội số (Flatten)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Làm phẳng dãy bằng bội số (Flatten)
Flatten
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , choose positive integers such that every product has the same value. Find the smallest possible sum , and print it modulo .
Input
The first line contains . The next line contains integers .
Output
Print the minimum sum modulo .
Subtasks
-
Subtask 1 (20 points): , .
-
Subtask 2 (30 points): , .
-
Subtask 3 (50 points): , .
Examples
Input
3
2 3 4
Output
13
Explanation
Choose . Then and the sum is . The common product is the smallest positive multiple of , hence the sum cannot be smaller.