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

#GL0000015. Làm tích chia hết cho lũy thừa hai (Divisibility by 2^n)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Làm tích chia hết cho lũy thừa hai (Divisibility by 2^n)

Divisibility by 2^n

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn positive integers, make their product divisible by 2n2^n. An operation chooses index ii and replaces aia_i with ai⋅ia_i\cdot i. Each index may be used at most once. Find the minimum number of operations or -1 if impossible.

Input

First line nn; second line nn integers aia_i.

Output

Print the minimum operations or -1.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201 \le n \le 20; 1≤ai≤1001 \le a_i \le 100
  • Subtask 2 (30 points): 1≤n≤20001 \le n \le 2000; 1≤ai≤1061 \le a_i \le 10^{6}
  • Subtask 3 (50 points): 1≤n≤2⋅1051 \le n \le 2\cdot 10^{5}; 1≤ai≤1091 \le a_i \le 10^{9}

Examples

Input

4
1 2 3 4

Output

1

Explanation

The initial product contains three factors of 22. One operation at index 22 or 44 increases that count to at least four.