The Battle
Practice
5 (2 votes)
Mathematics
Medium
Open
Approved
Problem
78% Success 1742 Attempts 30 Points 5s Time Limit 256MB Memory 1024 KB Max Code

The Battle between Shinigami's in the Shinigami world has gone to new levels. They are fighting each other for notebooks of death.
They are standing at such positions that vertices form a convex polygon ( a convex polygon has all of its interior angles less than 180 degrees). Each one of them fights some other Shinigami's. So we have diagonals in the polygon depicting who fight whom.
The rule being followed in this battle states that no three diagonals will intersect in a point in the given polygon.
Supposing that no three diagonals will intersect in a point in the given polygon, you have to find the number of intersections between all pairs of diagonals in the polygon.

Shown is one such polygon for N=6.
enter image description here

Input
First line of input contains N, denoting the number of vertices of given polygon.

Output
Output the required output on one line modulo 1000000007.

Constraints
3 <= N <= 10^7

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
99 votes
Tags:
MathematicsMediumOpenApproved
Points:30
70 votes
Tags:
ReadyMathematicsMedium