#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2e5;
int n, a[MaxN + 5], c[MaxN + 5];
int main() {
  while (~scanf("%d", &n)) {
    memset(c, 0, sizeof(c));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      c[a[i]]++;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= a[n]; i++) c[i] += c[i - 1];
    long long cnt = 0, ans = 0;
    for (int i = 1; i <= n; i++)
      if (a[i] != a[i - 1]) {
        cnt = 0;
        for (int j = 1; a[i] * j <= a[n]; j++) {
          int now = a[i] * j;
          cnt = cnt +
                (long long)now * (c[min(now + a[i] - 1, a[n])] - c[now - 1]);
        }
        ans = max(ans, cnt);
      }
    printf("%lld\n", ans);
  }
  return 0;
}
