#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 20;
int n, a[N], f[N];
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]), f[a[i]]++;
  for (int i = 1; i < N; i++) f[i] += f[i - 1];
  for (int i = 1; i < N; i++) {
    if (f[i] - f[i - 1] == 0) continue;
    long long sum = 0;
    for (int j = i; j + i - 1 < N; j += i)
      sum += 1ll * j * (f[j + i - 1] - f[j - 1]);
    ans = max(ans, sum);
  }
  printf("%lld", ans);
}
