# https://shakayami.hatenablog.com/entry/2021/01/01/044946 class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): assert 0<=p0): s+=self.data[r-1] r-=r&-r return s #x^2<=Kとなる最大のxを返す def sqrt(K): low=0 high=K+10 while(high-low>1): mid=(high+low)//2 if mid*mid<=K: low=mid else: high=mid return low def solve(A): N=len(A) maxA=max(A) sqrtmaxA=sqrt(maxA) L=[0 for i in range(sqrtmaxA)] BIT=fenwick_tree(maxA+1) ans=0 for i in range(N): if A[i]