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

#GL0000128. Chia và cân bằng (Divide and Equalize)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Chia và cân bằng (Divide and Equalize)

Divide and Equalize

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn positive integers, an operation chooses distinct indices i,ji,j and a positive divisor xx of aia_i, then replaces aia_i with ai/xa_i/x and aja_j with ajxa_jx. Any number of operations, including zero, is allowed. Decide whether all elements can become equal.

Input

The first line contains nn; the second contains nn integers aia_i.

Output

Print YES if all values can be made equal, and NO otherwise.

Subtasks

  • Subtask 1 (20 points): 1≤n≤101\le n\le 10; 1≤ai≤1001\le a_i\le 100.
  • Subtask 2 (30 points): 1≤n≤1 0001\le n\le 1\,000; 1≤ai≤10 0001\le a_i\le 10\,000.
  • Subtask 3 (50 points): 1≤n≤10 0001\le n\le 10\,000; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000.

Examples

Input

5
100 2 50 10 1

Output

YES

Explanation

Transfer factor 5 from 50 to 2, obtaining [100,10,10,10,1]. Then transfer factor 10 from 100 to 1 to obtain five copies of 10.