n = int(input()) a = list(map(int, input().split())) MX = 2 * 10 ** 5 c = [0] * (MX + 1) for ai in a: c[ai] += 1 s = [0] * (MX + 1) cs = [0] * (MX + 1) for i in range(1, MX + 1): s[i] = s[i-1] + c[i] * i cs[i] = cs[i-1] + c[i] ans = 0 for d in range(1, MX + 1): t = 0 for i in range(0, MX + 1, d): j = min(MX + 1, i + d) t += s[j - 1] - s[i] - (cs[j - 1] - cs[i]) * i ans += t * c[d] print(ans)