AtCoder Grand Contest 028
B
Removing Blocks
AtCoder
⌀ 2172
原题
← AC →
翻译中…

Problem Statement

翻译中…

There are $N$ blocks arranged in a row, numbered $1$ to $N$ from left to right. Each block has a weight, and the weight of Block $i$ is $A_i$. Snuke will perform the following operation on these blocks $N$ times:

翻译中…
  • Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of the blocks that are connected to the block being removed (including itself). Here, two blocks $x$ and $y$ ( $x \leq y$ ) are connected when, for all $z$ ( $x \leq z \leq y$ ), Block $z$ is still not removed.
翻译中…

There are $N!$ possible orders in which Snuke removes the blocks. For all of those $N!$ orders, find the total cost of the $N$ operations, and calculate the sum of those $N!$ total costs. As the answer can be extremely large, compute the sum modulo $10^9+7$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 10^5$
  • $1 \leq A_i \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 ... A_N

翻译中…

Output

翻译中…

For all of the $N!$ orders, find the total cost of the $N$ operations, and print the sum of those $N!$ total costs, modulo $10^9+7$.

翻译中…

样例

Input #1
2
1 2
Output #1
9
First, we will consider the order "Block $1$ -> Block $2$". In the first operation, the cost of the operation is $1+2=3$, as Block $1$ and $2$ are connected. In the second operation, the cost of the operation is $2$, as only Block $2$ remains. Thus, the total cost of the two operations for this order is $3+2=5$. Then, we will consider the order "Block $2$ -> Block $1$". In the first operation, the cost of the operation is $1+2=3$, as Block $1$ and $2$ are connected. In the second operation, the cost of the operation is $1$, as only Block $1$ remains. Thus, the total cost of the two operations for this order is $3+1=4$. Therefore, the answer is $5+4=9$.
Input #2
4
1 1 1 1
Output #2
212
Input #3
10
1 2 4 8 16 32 64 128 256 512
Output #3
880971923
题目信息
题号
agc028_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。