ll z,a,b[4d5],c[4d5];{rd(*b);rep(*b)rd(a),++c[a];rrep(a,1,3d5){b[a]=b[a+1]-c[a];rep(t,0,3d5,a)z+=c[a]*a*b[t];}wt(z);}