#C. C - Not Equal

    传统题 1000ms 256MiB

C - Not Equal

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

C - Not Equal

Score : $300$ points

Problem Statement

You are given a sequence $C$ of $N$ integers. Find the number of sequences $A$ of $N$ integers satisfying all of the following conditions.

  • $1 \leq A_i \leq C_i\, (1 \leq i \leq N)$
  • $A_i \neq A_j\, (1 \leq i < j \leq N)$

Since the count may be enormous, print it modulo $(10^9+7)$.

Constraints

  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq C_i \leq 10^9$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

C1C_1 C2C_2 \ldots CNC_N

Output

Print the number of sequences $A$ of $N$ integers satisfying all of the following conditions, modulo $(10^9+7)$.


2
1 3
2

We have two sequences $A$ satisfying all of the conditions: $(1,2)$ and $(1,3)$.
On the other hand, $A=(1,1)$, for example, does not satisfy the second condition.


4
3 3 4 4
12

2
1 1
0

We have no sequences $A$ satisfying all of the conditions, so we should print $0$.


10
999999917 999999914 999999923 999999985 999999907 999999965 999999914 999999908 999999951 999999979
405924645

Be sure to print the count modulo $(10^9+7)$.

2025寒假ATC码力训练营第九次练习

未参加
状态
已结束
规则
IOI
题目
6
开始于
2025-2-1 13:00
结束于
2025-2-1 14:30
持续时间
1.5 小时
主持人
参赛人数
5