Under construction

Still being built. Things may change

Lazdynas

Interview

Time limit1sMemory limit1024 MB

Summary
Given N nut coordinates, find the maximum number of nuts Squirrel Vytis can catch when the tree chooses the drop order.
Level

Medium5 of 10

Topics
Greedy, Hash map, Sorting
Solved
No attempts yet

Problem

A friendly hazel tree grows near the home of the squirrel Vytis and drops nuts for him. Vytis starts at position 0. Nuts hang high on a horizontal branch of the tree, and the NN nuts are at coordinates x1,…,xNx_1, \dots, x_N. The tree drops the nuts one at a time, and the effect of each drop is as follows. If a nut falls to the left or right of Vytis, he moves one position in that direction and does not catch the nut. If a nut falls exactly on Vytis's head, he catches it and does not move. The tree chooses the order of the drops so that Vytis catches as many nuts as possible.

Input

The first line contains the number of nuts NN. Each of the next NN lines contains one integer, where the integer on line ii is the coordinate xix_i of the ii-th nut.

Output

Print one integer, the maximum number of nuts Vytis can collect.

Constraints

1≤N≤100 0001 \le N \le 100\,000, and each xix_i satisfies −1 000 000 000≤xi≤1 000 000 000-1\,000\,000\,000 \le x_i \le 1\,000\,000\,000.

Examples1

  1. Example 1

    Input
    5
    1 2 -1 2 -2
    
    Expected output
    2