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

#GL0000141. Mike và bài toán ƯCLN (Mike and gcd problem)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Mike và bài toán ƯCLN (Mike and gcd problem)

Mike and gcd problem

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Mike has an array A=[a1,a2,…,an]A=[a_1,a_2,\ldots,a_n]. An array is beautiful when the GCD of all its elements is greater than 11.

In one operation, choose adjacent positions i,i+1i,i+1. If their values were x,yx,y, replace them simultaneously, in that order, by x−yx-y and x+yx+y. Values may become zero or negative. Compute the GCD using absolute values; for example, the GCD of −6,0,9-6,0,9 is 33.

Determine whether the array can become beautiful, and find the minimum number of operations if possible.

Input

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

Output

Print YES if a beautiful array is achievable, otherwise NO. If you print YES, print the minimum number of operations on the second line. Preserve capitalization.

Subtasks

  • Subtask 1 (20 points): 2≤n≤162\le n\le 16; 1≤ai≤301\le a_i\le 30.
  • Subtask 2 (30 points): 2≤n≤1 0002\le n\le 1\,000; 1≤ai≤100 0001\le a_i\le 100\,000.
  • Subtask 3 (50 points): 2≤n≤100 0002\le n\le 100\,000; 1≤ai≤1 000 000 0001\le a_i\le 1\,000\,000\,000.

Examples

Input

2
1 3

Output

YES
1

Explanation

The original pair has GCD 11. One operation transforms (1,3)(1,3) into (−2,4)(-2,4), whose GCD is 2>12>1. Since the initial array was not beautiful, one operation is optimal.