Max Convolution
题号:NC15839
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Alice has an array , she want to calculate the other array where

Can you help her? For simplicity, please output

输入描述:

In the first line there are two integer n, m,(1 <= n <= 100000, 1 <= m <= 1000000000).
In the second line there are n integers .

输出描述:

Output a single integer, which is
示例1

输入

复制
5 2
1 10 6 10 8

输出

复制
4985

说明

b_0 = a_0\cdot a_0 = 1
b_1 = a_0\cdot a_1 + a_1\cdot a_0 + a_1\cdot a_1= 120
b_2 = a_0\cdot a_2 + a_1\cdot a_2 + a_2\cdot a_0 + a_2\cdot a_1 + a_2\cdot a_2 = 168
b_3 = a_0\cdot a_3 + a_1\cdot a_3 + a_2\cdot a_3 + a_3\cdot a_0 + a_3\cdot a_1 + a_3\cdot a_2 + a_3\cdot a_3 = 440
b_4 = a_0\cdot a_4 + a_1\cdot a_4 + a_2\cdot a_4 + a_3\cdot a_4 + a_4\cdot a_0 + a_4\cdot a_1 + a_4\cdot a_2 + a_4\cdot a_3 + a_4\cdot a_4 = 496
ans = 1\cdot b_0 + 2\cdot b_1 + 3\cdot b_2 + 4\cdot b_3 + 5\cdot b_4 = 4985
示例2

输入

复制
10 3
83254494 79256570 664815211 929105503 348307749 129917295 141270181 116122929 432020021 461745049

输出

复制
964655557