← Home
```go
package main

import (
	"fmt"
	"io"
	"os"
)

const MOD int64 = 1000000007

func modPow(a, e int64) int64 {
	res := int64(1)
	for e > 0 {
		if e&1 == 1 {
			res = res * a % MOD
		}
		a = a * a % MOD
		e >>= 1
	}
	return res
}

func main() {
	data, _ := io.ReadAll(os.Stdin)
	idx := 0
	nextInt := func() int64 {
		for idx < len(data) && (data[idx] == ' ' || data[idx] == '\n' || data[idx] == '\r' || data[idx] == '\t') {
			idx++
		}
		val := int64(0)
		for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
			val = val*10 + int64(data[idx]-'0')
			idx++
		}
		return val
	}

	n := int(nextInt())
	m := nextInt()
	v := nextInt() % MOD

	a := make([]int64, n+1)
	for i := 1; i <= n; i++ {
		a[i] = nextInt() % MOD
	}

	invN := modPow(int64(n), MOD-2)

	dp := make([]int64, n+2)
	ndp := make([]int64, n+2)
	dp[0] = 1

	for i := 1; i <= n; i++ {
		for j := 0; j <= i; j++ {
			ndp[j] = 0
		}
		start := v * int64(i) % MOD * invN % MOD
		for l := 0; l < i; l++ {
			val := dp[l]
			if val == 0 {
				continue
			}
			keep := (a[i] + v*int64(l)) % MOD
			ndp[l] = (ndp[l] + val*keep) % MOD
			ndp[l+1] = (ndp[l+1] + val*start) % MOD
		}
		dp, ndp = ndp, dp
	}

	ans := int64(0)
	fall := int64(1)
	for l := 0; l <= n; l++ {
		ans = (ans + dp[l]*fall) % MOD
		if l < n {
			if int64(l) >= m {
				fall = 0
			} else {
				fall = fall * (m - int64(l)) % MOD
			}
		}
	}

	fmt.Print(ans)
}
```