思路:按照题意 我们先固定两个数构成一个逆序对 无论其他位置的数怎么变 固定的对答案的贡献一直为1 所以对于长度为n的序列有图片说明 种摆法
那对于其他的不是0就是1 那一共有 图片说明

所以答案为图片说明 因为有除法运算的存在 且 模数是个质数 直接快速幂就好了

#include <bits/stdc++.h>

using namespace std;

#define LL long long

const LL mod = 1e9 + 7;

LL quickpow(LL a,LL b)
{
    LL res = 1;

    while(b)
    {
        if(b&1)
            res = res*a%mod;
        b >>= 1;

        a = a*a%mod;
    }

    return res;
}

int main()
{
    LL n ;

    cin >> n;

    if(n == 1)
        cout << 0 ;
    else
    {
        LL c = (((n % mod *((n - 1)%mod))%mod)*(quickpow(2LL,mod-2)%mod)%mod);
        LL m = quickpow(2LL,n - 2)%mod;

        LL res = (c%mod * m % mod)%mod;

        cout << res;
    }

    cout << '\n';

    return 0;
}