#SP0000250. Lũ nguyên tố — Phiên bản dễ (A Prime Flood — Easy Version)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lũ nguyên tố — Phiên bản dễ (A Prime Flood — Easy Version)
A Prime Flood (Easy Version)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer array represents water levels. Independently for every non-empty subsequence chosen by selecting positions from and keeping their order, consider the following operation: choose any prime and simultaneously decrease by exactly every current element of divisible by . All other elements remain unchanged. Any number of operations, including zero, may be performed.
Let be the maximum integer such that all elements of can be made equal to . Calculate
Different choices of indices count as different subsequences, even when their value sequences coincide. Each subsequence is processed independently from its original values.
Input
- The first line contains integer , the array length.
- The second line contains exactly integers in their original order.
Output
Print one integer, the sum of over all non-empty subsequences distinguished by selected indices, modulo .
Subtasks
- Subtask 1 (20 points): ; for all .
- Subtask 2 (30 points): ; for all .
- Subtask 3 (50 points): ; for all .
Examples
Input
4
2 4 4 4
Output
37
Explanation
For , choose a non-empty subset of the three positions equal to without choosing the : there are such subsequences, each with , contributing . The subsequence consisting only of contributes . Finally there are selections containing the and at least one ; each has because the values can be reduced to but cannot be equalized at or more. Thus the total is .