#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int MAX = 1234567;
int a[N];
int pre[MAX];
bool done[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    pre[a[i]]++;
  }
  for (int i = 0; i + 1 < MAX; i++) pre[i + 1] += pre[i];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (done[a[i]]) continue;
    long long res = 0;
    for (int j = 1; (long long)a[i] * j < N; j++) {
      res +=
          (long long)a[i] * (pre[j * a[i] + a[i] - 1] - pre[j * a[i] - 1]) * j;
    }
    ans = max(ans, res);
    done[a[i]] = 1;
  }
  printf("%lld\n", ans);
  return 0;
}
