Type: Default 1000ms 256MiB

染色

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

nn 个点染色,每个点都需要一种独一无二的颜色。颜色以数字编号,每个点对颜色都有各自的要求。其中第 ii 个点要求颜色的编号为 11aia_i之间的整数。

请统计有多少种染色方案数满足要求,由于答案可能很大,输出模 109+710^9 + 7的余数。

Format

Input

第一行:单个整数表示 nn

第二行:nn 个整数表示 a1,a2,,ana_1, a_2, \dots, a_n

Output

单个整数表示答案

Samples

样例输入

3
4 7 2

样例输出

30

Limitation

30%30\% 的数据,1n10,1ai101 \leq n \leq 10, 1 \leq a_i \leq 10

60%60\% 的数据,1n100,1ai1001 \leq n \leq 100, 1 \leq a_i \leq 100

100%100\% 的数据,1n300000,1ai1091 \leq n \leq 300000, 1 \leq a_i \leq 10^9

20241128周赛

Not Attended
Status
Done
Rule
IOI
Problem
6
Start at
2024-11-28 16:30
End at
2024-11-28 18:30
Duration
2 hour(s)
Host
Partic.
25