ll n,u,z,a,b[3d5],c[3d5]; { rd(n); REP(n)rd(a),++c[a]; RREP(a,1,2d5+1){ b[a]=b[a+1]-c[a]; u=n; REP(t,a,2d5+1,a)u+=b[t]; z+=u*a*c[a]; } wt(z); }