Triangle Sticks

No attempts yetTime limit1sMemory limit512 MB

Problem

Jaś loves building triangles out of sticks. He keeps the sticks in a bag and draws three of them at random. Because the sticks have different lengths, three drawn sticks cannot always form a triangle, and when they cannot, Jaś throws a tantrum. To prevent this, we want to throw away some of the sticks so that any three of the sticks left in the bag can form a triangle, while keeping as many sticks as possible.

Three sticks of lengths aa, bb, cc form a triangle when the sum of every two of them is greater than the third; equivalently, if abca \le b \le c, they form a triangle exactly when a+b>ca + b > c (a flat, degenerate triangle does not count).

Write a program that:

  • reads the number of sticks in the bag and the length of each stick,
  • computes the maximum number of sticks that can be kept so that every three of the kept sticks form a triangle,
  • prints that number.

Input

The first line contains an integer NN (5N300005 \le N \le 30\,000), the number of sticks in the bag. Each of the next NN lines contains one integer, the length of a stick. Every length is an integer between 11 and 500500 inclusive.

Output

Print one line: the maximum number of sticks that can remain in the bag so that any three of them form a triangle.