TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Given a set of integers, how many different triangles can you construct by using three distinct numbers in the set?
For example, let the set be {1, 3, 4, 5, 7, 8}.
The 7 different triangles can be constructed were (3,4,5), (3,5,7), (4,5,7), (3,7,8), (4,7,8), (5,7,8), (4,5,8).

Input Format

There are multiple test cases.
The first line of each test case contains two integers N (1<= N<=1000000000) and M (0<= M<=1000).
The second line containing M distinct integers a1, a2, ..., aM.

Output Format

For each test case, please compute the number of different triangles you can construct
by using the set {1, 2, ..., N} - {a1, a2, ..., aM}.
Output the answer mod 1000000007.

Sample Input 1

8 2
2 6
58 3
23 5 3

Sample Output 1

7
13861

Hints

Problem Source

Migrated from old NTUJ.

Bee

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 524288 200