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

#GD0000121. Sưu tầm nhiều mệnh giá tiền xu (Coin Collector)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Sưu tầm nhiều mệnh giá tiền xu (Coin Collector)

Coin Collector

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

A bank has denominations c1<c2<⋯<cnc_1<c_2<\cdots<c_n with c1=1c_1=1. When withdrawing an arbitrary positive integer XX, it repeatedly gives the largest coin not exceeding the remaining amount until fully paid. Maximize the number of distinct denominations obtained in one withdrawal.

Input

The first line has nn. The second line contains nn strictly increasing denominations cic_i.

Output

Print the maximum number of distinct denominations.

Subtasks

  • Subtask 1 (20 points): 1≤n≤101\le n\le 10; c1=1c_1=1; 1≤c1<c2<⋯<cn<1091\le c_1<c_2<\cdots<c_n<10^9.
  • Subtask 2 (30 points): 1≤n≤1001\le n\le 100; c1=1c_1=1; 1≤c1<c2<⋯<cn<1091\le c_1<c_2<\cdots<c_n<10^9.
  • Subtask 3 (50 points): 1≤n≤10001\le n\le 1000; c1=1c_1=1; 1≤c1<c2<⋯<cn<1091\le c_1<c_2<\cdots<c_n<10^9.

Examples

Input

6
1 3 6 8 15 20

Output

4

Explanation

With withdrawal 3030, the bank gives 20,6,3,120,6,3,1, totaling four different denominations. The greedy payment rule prevents simultaneously including all other denominations.