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

#DSU0000076. Cuộc chạy trốn của Neo (Neo’s Escape)

HỌC THEO LỘ TRÌNH

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

2 lộ trình

Cuộc chạy trốn của Neo (Neo’s Escape)

Neo’s Escape

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Neo faces nn buttons in a row, with weight aia_i on button ii. He cannot move himself but may create a clone at any button, or move an existing clone left or right by one position.

A clone immediately presses every unpressed button it reaches. Each button is pressed at most once. Neo must press all buttons in a non-increasing order of their weights. Find the minimum number of clones required.

Neo may create multiple clones, each at any button. Once created, a clone can move only between adjacent buttons. Whenever a clone reaches an unpressed button, it must press that button immediately; it cannot pass through without pressing it.

Neo chooses when to create and move clones, provided every button is pressed exactly once and the weights in the order of pressing form a non-increasing sequence. Buttons having equal weights may be pressed in any order.

Input

The first line contains nn. The second contains the weights a1,…,ana_1,\ldots,a_n.

Output

Print one integer: the minimum number of clones required.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30; 1≤ai≤1091\le a_i\le10^9.
  • Subtask 2 (30 points): 1≤n≤40001\le n\le 4000; 1≤ai≤1091\le a_i\le10^9.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; 1≤ai≤1091\le a_i\le10^9.

Examples

Input

5
4 3 2 1 5

Output

2

Explanation

Button 55 must be pressed before all lower-weight buttons. Create one clone to press 55 and a second clone to press 44, then move the latter along the buttons of weights 3,2,13,2,1. One clone cannot suffice: moving from weight 55 toward weight 44 would force it to press some smaller-weight buttons too early.