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

#GL0000123. Tăng ƯCLN của dãy (Enlarge GCD)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tăng ƯCLN của dãy (Enlarge GCD)

Enlarge GCD

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn positive integers a1,…,ana_1,\ldots,a_n, you may remove elements but must keep at least one. Find the minimum number of removals so that the GCD of all remaining values is strictly greater than the original array GCD. Print -1 if this is impossible.

Input

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

Output

Print the minimum number of removals, or -1.

Subtasks

  • Subtask 1 (20 points): 2≤n≤402\le n\le 40; 1≤ai≤5001\le a_i\le 500.
  • Subtask 2 (30 points): 2≤n≤5 0002\le n\le 5\,000; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000.
  • Subtask 3 (50 points): 2≤n≤300 0002\le n\le 300\,000; 1≤ai≤15 000 0001\le a_i\le 15\,000\,000.

Examples

Input

3
1 2 4

Output

1

Explanation

The original GCD is 1. Removing the first element leaves 2 and 4, whose GCD is 2. One removal is minimal.