#SP0000252. Biến đổi bằng số nguyên tố (Move by Prime)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Biến đổi bằng số nguyên tố (Move by Prime)
Move by Prime
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array of positive integers , independently consider all subsequences, including the empty subsequence. Different selections of indices are counted separately.
For each subsequence, make all its elements equal using the minimum number of operations. Each operation affects one chosen element and either multiplies it by an arbitrary prime or divides it by a prime that divides the element (the quotient must be an integer).
The cost of a subsequence is the minimum number of operations needed to make all its elements equal. Empty and singleton subsequences have cost . Find the sum of all these minimum costs, modulo .
Input
The first line contains the number of elements .
The second line contains exactly integers in order.
Output
Print a single integer: the sum of minimum operation counts over all subsequences, modulo .
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
3
60 60 40
Output
6
Explanation
Of the subsequences, needs two operations: divide by to obtain , then multiply by to obtain . A single operation is insufficient because is neither a prime nor the reciprocal of a prime.
There are two index-distinct subsequences containing one and one , each costing . All the remaining subsequences (the pair , the singletons, and the empty subsequence) cost . Thus the total is .