Python 代码
n = int(input())
C = [[0] * (n+1) for _ in range(n+1)]
mod = int(1e9+7)
for a in range(n+1):
for b in range(a+1):
if b == 0: C[a][b] = 1
else: C[a][b] = (C[a-1][b-1] + C[a-1][b]) % mod
res = 0
for k in range(2, n-1):
res = (res + (C[n-1][k] * (k-1) * (n-k-1))) % mod
print(res)