Wrong Envelop

Time Limit: 1000 ms Memory Limit: 65536 KiB

Problem Description

Lin sometimes can be very careless. One day, he wrote n letter(s), but he put each of them in the wrong envelop. How many are the way(s) can he do this identically(different arrangement of the letter-envelop combinations). Because the number can be very big, to avoid the precision problem, modulo each number by 2014.
 

Input

Multiple input cases. n < 250001.
 

Output

The answer.
 

Sample Input

1
2
3
4

Sample Output

0
1
2
9

Hint

Modulo each number in each step you calculate. It’s ok.

Source

zhengnanlee