#K38337. Unique Deck Configurations

    ID: 26176 Type: Default 1000ms 256MiB

Unique Deck Configurations

Unique Deck Configurations

In this problem, you are given a deck of n cards. A configuration of the deck is a particular permutation of these cards. The problem asks you to determine the number of unique configurations that can be obtained before the deck returns to its original order if one considers every possible permutation except the original order.

Mathematically, for n > 1, the answer is computed as:

\(n! - 1 \mod 10^9+7\)

Note that when n = 1, there is only one configuration (the original order), and therefore the result should be 0.

Your task is to read the integer n from stdin and output the number of unique configurations modulo \(10^9+7\> to stdout.

inputFormat

The input consists of a single integer n (1 ≤ n ≤ some large number), representing the number of cards in the deck. The integer is provided via standard input.

outputFormat

Output a single integer, which is the number of unique configurations as computed by (n! - 1 \mod 10^9+7). If n = 1, output 0. The result should be printed to standard output.## sample

1
0