Skip to main content
2 of 4
added 76 characters in body

Sum of the sum of all possible subsets raised to power k

You are given an array A of non-negative integers. You can pick any non-empty subset, S from the array A. The score of a subset S is the sum of the elements in S raised to the power of K, i.e. for a subset S={s1,s2,…,sm}, the score of S is (s1+s2+…,sm)K. Output the sum of scores over all possible non-empty subsets of A modulo 109 + 7.

Input

The first line consists of two integers N (1 ≤ N ≤ 1000) and K (1 ≤ K ≤ 300), Then N integers follow: a1,a2…,an (1 ≤ ai ≤ 109)

Examples

Input:

3 2
1 2 4

Output:

140

Note

There are 7 possible non empty subsets:

{1}, 12=1

{2}, 22=4

{4}, 42=16

{1,2}, 32=9

{1,4}, 52=25

{2,4}, 62=36

{1,2,4}, 72=49

The total of all of them is 140.

Scoring

this is code-golf, so the shortest code in bytes wins