4486: C. Array Concatenation

内存限制:512 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:Special Judge 上传者:
提交:15 通过:7

题目描述

Little relyt871 has a magical machine. In each operation, his machine can do one of the following operations to the input array b:
  • Generate a copy of b and concatenate it after b. More formally, the resulting array should be
    b′={b1,b2,…,b|b|,b1,b2,…,b|b|}.
  • Generate a copy of b, reverse it, then concatenate it before b. More formally, the resulting array should be
    b′={b|b|,b|b−1|,…,b1,b1,b2,…,b|b|}.
Initially, he has an array a of length n. Then, he wants to operate the machine exactly m times using the array on his hand while maximizing the sum of all prefix sums of the final array. Since he has a somewhat finite brain, when he adds some integers, he only cares about the sum modulo 1,000,000,007. Formally, suppose after all m operations he has array b of length n', he wants to maximize the following value: 
Please note that you should maximize the value after taking the modulo: the array with answer 1,000,000,007 before taking the modulo is considered less than the array with answer 1.

输入格式

The first line contains two integers n and m (1<= n,m<= 105).
The second line contains n integers a1, a2, ..., an (1 <= ai <= 109) separated by spaces.

输出格式

Print a single integer in one line, denoting the answer.

输入样例 复制

2 1
1 2

输出样例 复制

15

数据范围与提示

input
5 10
26463 39326 86411 75307 85926
output

806275469

分类标签