local n = io.read("*n") local t = {} local lim = 200000 local cnt = {} for i = 1, lim do t[i] = 0 cnt[i] = 0 end local a = {} for i = 1, n do a[i] = io.read("*n") t[a[i]] = t[a[i]] + a[i] cnt[a[i]] = cnt[a[i]] + 1 end local sum = {t[1]} local cntsum = {cnt[1]} for i = 2, lim do sum[i] = sum[i - 1] + t[i] cntsum[i] = cntsum[i - 1] + cnt[i] end local ans = 0LL for i = 2, lim do local mul = cnt[i] local j = 1 while true do local left = (j - 1) * i local right = j * i - 1 if lim < left then break end if lim < right then right = lim end local raw = sum[right] local c = cntsum[right] if 1 < left then raw = raw - sum[left - 1] c = c - cntsum[left - 1] end -- do -- print(i, j, raw, c * i * (j - 1) * mul, -- raw - c * i * (j - 1) * mul) -- end raw = (raw - c * i * (j - 1)) * mul ans = ans + raw j = j + 1 end end ans = tostring(ans):gsub("LL", "") print(ans)