emmm,我觉得是水题. 另外存下__int128的输入输出~好困啊!

#include <bits stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+50;
ll n;
ll w[N],c[N],val[N],ls[N];
int lowbit(int x)	{ return x&amp;(-x); }
__int128 read(){
    __int128 x=0,f=1;
    char ch=getchar();
    while(!isdigit(ch)&amp;&amp;ch!='-')ch=getchar();
    if(ch=='-')f=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
inline void print(__int128 x)
{    
   if(x&lt;0){putchar('-');x=-x;}
   if(x&gt;9) print(x/10);
   putchar(x%10+'0');
}
void add(ll u,ll x)
{
	while(u&lt;=n)
	{
		c[u]+=x;
		u+=lowbit(u);
	}
}

ll query(ll u)
{
	ll res=0;
	while(u)
	{
		res+=c[u];
		u-=lowbit(u);
	}return res;
}

int main()
{
	scanf("%lld",&amp;n);__int128 ans=0;
	for(ll i=1;i&lt;=n;i++)
	{
		scanf("%lld",&amp;w[i]);ls[i]=w[i];
	}sort(ls+1,ls+1+n);
	ll cnt=unique(ls+1,ls+1+n)-ls-1;
	for(ll i=1;i&lt;=n;i++)
	{
		w[i]=lower_bound(ls+1,ls+1+cnt,w[i])-ls;
	}
	for(ll i=n;i&gt;=1;i--)
	{
		ans+=(i)*(query(w[i]-1));
		add(w[i],n-i+1);
	}print(ans);
	return 0;
}
```</bits>