Algorithm


Problem link- https://www.spoj.com/problems/DIG/

DIG - DIAGONAL

no tags 

 

You are a given a n sided convex polygon. Find total number of intersections of all diagonals.

Assume that all the intersection points are different.

If in case answer exceeds 10^9 + 7 , take modulo 10^9 + 7

1<=n<=10^8

Input

First Line : T (number of test cases)

Next T line will contain N number of vertices

Output

Number of intersections of diagonals as specified.

Example

Input:
2
4
5
Output:
1
5

 

Code Examples

#1 Code Example with Python Programming

Code - Python Programming

T = int(input())
for i in range(T):
    N = int(input())
    print (N * (N - 1) * (N - 2) * (N - 3) // 24 % 1000000007)
Copy The Code & Try With Live Editor

Input

x
+
cmd
2
4
5

Output

x
+
cmd
1
5
Advertisements

Demonstration


SPOJ Solution-DIAGONAL-Solution in C, C++, Java, Python

Previous
SPOJ Solution - Test Life, the Universe, and Everything - Solution in C, C++, Java, Python