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

#GL0000045. Sherlock và UCLN của một dãy con (Sherlock and GCD)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Sherlock và UCLN của một dãy con (Sherlock and GCD)

Sherlock and GCD

Source: HackerRank

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array of NN positive integers, determine whether there exists a nonempty subset with no repeated values whose GCD is 11. The selected elements need not be consecutive.

Input

First line: NN. Second line: NN positive integers aia_i.

Output

Print YES if such a subsequence exists, otherwise NO.

Subtasks

  • Subtask 1 (20 points): 1≤N≤71 \le N \le 7; 1≤ai≤1001 \le a_i \le 100
  • Subtask 2 (30 points): 1≤N≤10001 \le N \le 1000; 1≤ai≤1061 \le a_i \le 10^{6}
  • Subtask 3 (50 points): 1≤N≤1051 \le N \le 10^{5}; 1≤ai≤1091 \le a_i \le 10^{9}

Examples

Input

3
2 4 3

Output

YES

Explanation

The subsequence 2,32,3 has two elements with GCD 11, so the answer is YES.