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

#GL0000225. Đặt bẫy bắt nhiều ếch nhất (We Were Both Children)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đặt bẫy bắt nhiều ếch nhất (We Were Both Children)

We Were Both Children

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn frogs starting at coordinate 00; frog ii repeatedly jumps forward by aia_i. You may place one trap at an integer coordinate p∈[1,n]p\in[1,n]. A frog is caught iff ai∣pa_i\mid p. Find the maximum number caught. Equal jump lengths still correspond to different frogs.

Input

First line contains nn; second line contains aia_i.

Output

Print the maximum number of frogs.

Subtasks

  • Subtask 1 (20 points): 1≤n≤50, 1≤ai≤10001\le n\le 50,\ 1\le a_i\le 1000.

  • Subtask 2 (30 points): 1≤n≤5000, 1≤ai≤10000001\le n\le 5000,\ 1\le a_i\le 1000000.

  • Subtask 3 (50 points): 1≤n≤200000, 1≤ai≤10000000001\le n\le 200000,\ 1\le a_i\le 1000000000.

Examples

Example 1

Input

5
1 2 3 4 5

Output

3

Explanation

Placing the trap at coordinate 4 catches the frogs of jump lengths 1,2 and 4, for a total of three.

Example 2

Input

3
2 2 2

Output

3

Explanation

A trap at coordinate 2 catches all three frogs.

Example 3

Input

1
10

Output

0

Explanation

The frog lands only at 10,20,..., but the sole allowed trap location is coordinate 1.