N = gets.to_i A = gets.split.map(&:to_i) M = A.max C = Array.new(M + 1, 0) D = Array.new(M + 1, 0) ans = 0 A.each do |a| C[a] += 1 ans += a end ans *= N M.downto(1) do |i| C[i - 1] += C[i] end 1.upto(M) do |i| i.step(M, i) do |j| D[i] += C[j] end end A.each do |a| ans -= D[a] * a end puts ans