Yet Another Contest 4 P5 - Signpost

View as PDF

Submit solution


Points: 20 (partial)
Time limit: 2.0s
Python 4.0s
Memory limit: 512M

Author:
Problem type

Australia consists of a single long road from west to east. There are N stores along this road, with the i-th store having an integer position of pi.

You have been commissioned to design and install a signpost. First, you will choose a real number K, representing the position of the signpost. Let di=|piK| represent the distance from the signpost to the i-th store. The signpost will contain all N stores on it in some order from top to bottom, under the condition that if di<dj, then store i is listed higher up on the signpost than store j. If two stores are equidistant from the signpost, then you can decide which of stores i and j is listed higher up the signpost.

Your first task is to calculate how many distinct signposts you could make. Since this number may be large, you want to find this number modulo 109+7.

Constraints

1N5×105

1pi5×105

All pi are distinct.

Subtask 1 [50%]

1N3000

Subtask 2 [50%]

No additional constraints.

Input Specification

The first line contains a single integer, N.

The second line contains N space-separated integers, p1,p2,,pN.

Output Specification

On a single line, print the number of possible distinct signposts, modulo 109+7.

Sample Input

Copy
3
1 2 3

Sample Output

Copy
4

Explanation

Consider the case where the signpost is at position K=2. Then d1=1,d2=0,d3=1. From the top to bottom, the signpost could list stores 2 then 1 then 3, or stores 2 then 3 then 1.

If we consider all possible values of K, including non-integer and negative values, we see that there are 4 distinct signposts which can be made.


Comments

There are no comments at the moment.