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

#GL0000099. Koxia và lý thuyết số (Koxia and Number Theory)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Koxia và lý thuyết số (Koxia and Number Theory)

Koxia and Number Theory

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given a sequence of nn positive integers, determine whether there exists one common positive integer x>0x>0 such that gcd⁡(ai+x,aj+x)=1\gcd(a_i+x,a_j+x)=1 for every pair of distinct indices 1≤i<j≤n1\le i<j\le n. You only need to decide existence, not output xx.

Input

The first line contains nn. The second line contains nn integers a1,…,ana_1,\ldots,a_n.

Output

Print YES if such an xx exists; otherwise print NO.

Subtasks

  • Subtask 1 (20 points): 2≤n≤82\le n\le 8; 1≤ai≤2001\le a_i\le 200.
  • Subtask 2 (30 points): 2≤n≤402\le n\le 40; 1≤ai≤1091\le a_i\le 10^9.
  • Subtask 3 (50 points): 2≤n≤1002\le n\le 100; 1≤ai≤10181\le a_i\le 10^{18}.

Examples

Input

3
5 7 10

Output

YES

Explanation

Choosing x=4x=4 gives 9,11,149,11,14. Their pairwise GCDs are all 11, so the answer is YES.