class segtree(): def __init__(self,init,func,ide): self.n=len(init) self.func=func self.ide=ide self.size=1<<(self.n-1).bit_length() self.tree=[self.ide for i in range(2*self.size)] for i in range(self.n): self.tree[self.size+i]=init[i] for i in range(self.size-1,0,-1): self.tree[i]=self.func(self.tree[2*i], self.tree[2*i|1]) def update(self,k,x): k+=self.size self.tree[k]=x k>>=1 while k: self.tree[k]=self.func(self.tree[2*k],self.tree[k*2|1]) k>>=1 def get(self,i): return self.tree[i+self.size] def query(self,l,r): l+=self.size r+=self.size l_res=self.ide r_res=self.ide while l>=1 r>>=1 return self.func(l_res,r_res) def debug(self,s=10): print([self.get(i) for i in range(min(self.n,s))]) n=int(input()) a=sorted(list(map(int,input().split()))) ans=0 for i in range(n): ans+=a[i]*(n-1-i) m=2*10**5+10 seg=segtree([0]*m,lambda x,y:x+y,0) seg_cnt=segtree([0]*m,lambda x,y:x+y,0) for i in range(n-1,-1,-1): ai=a[i] tmp=1 while tmp*ai