PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000252. Biến đổi bằng số nguyên tố (Move by Prime)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

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 nn positive integers a1,a2,…,ana_1,a_2,\ldots,a_n, independently consider all 2n2^n 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 00. Find the sum of all these minimum costs, modulo 109+710^9+7.

Input

The first line contains the number of elements nn.

The second line contains exactly nn integers a1,a2,…,ana_1,a_2,\ldots,a_n in order.

Output

Print a single integer: the sum of minimum operation counts over all subsequences, modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le 20; 1≤ai≤3000001\le a_i\le 300000 for every 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000; 1≤ai≤3000001\le a_i\le 300000 for every 1≤i≤n1\le i\le n.
  • Subtask 3 (50 points): 1≤n≤3000001\le n\le 300000; 1≤ai≤3000001\le a_i\le 300000 for every 1≤i≤n1\le i\le n.

Examples

Input

3
60 60 40

Output

6

Explanation

Of the 23=82^3=8 subsequences, [60,60,40][60,60,40] needs two operations: divide 4040 by 22 to obtain 2020, then multiply 2020 by 33 to obtain 6060. A single operation is insufficient because 60/40=3/260/40=3/2 is neither a prime nor the reciprocal of a prime.

There are two index-distinct subsequences containing one 6060 and one 4040, each costing 22. All the remaining subsequences (the pair [60,60][60,60], the singletons, and the empty subsequence) cost 00. Thus the total is 2+2+2=62+2+2=6.