TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Enough with this Harry Potter, please! What are we, twelve-year olds? Let's get our teeth into some real pumpkin pasties -- oops, programming problems!

Here we go!

Let's define the diversity of a list of numbers to be the difference between the largest and smallest number in the list.

For example, the diversity of the list (1, -1, 2, 7) = 7 - (-1) = 8.

A substring of a list is considered a non-empty sequence of contiguous numbers from the list. For example, for the list (1,3,7), the substrings are (1), (3), (7), (1,3), (3,7), (1,3,7). A subsequence of a list is defined to be a non-empty sequence of numbers obtained by deleting some elements from the list. For example, for the list (1,3,7), the subsequences are (1), (3), (7), (1,3), (3,7), (1,7), (1,3,7).

Given a list of length N find the number of substrings and subsequences in this list with the maximum diversity. If a substring/subsequence having maximum diversity occurs multiple times in the list, each of its occurances adds towards the answer. And tell Harry Potter your answer.

Input Format

The first line contains T, the number of test cases. Then follow T test case blocks.

Each blocks starts with the first line containing the number N.

The second line contains a list of numbers in this list.

Output Format

For each test case, output the number of substrings and the number of subsequences in this list with the maximum diversity.

Since the answers maybe very large, output them modulo 1000000007.



Constraint


T <= 20

N <= 100,000

Each number in the list is between 1 and 100,000 inclusive.

Sample Input 1

3
3
1 2 3
4
1 4 3 4
3
3 2 1

Sample Output 1

1 2
3 6
1 2

Hints

Problem Source

Migrated from old NTUJ.

Regional Amritapuri 2011

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 2000 65536 200