#include <bits/stdc++.h>
using namespace std;
int n, a[200005], vis[200005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[a[i]]) {
      long long t = 0;
      for (int j = a[i];; j += a[i]) {
        int *t1 = lower_bound(a + 1, a + 1 + n, j);
        if (t1 == a + 1 + n) break;
        vis[j] = true;
        int *t2 = lower_bound(a + 1, a + 1 + n, j + a[i]);
        t += (long long)j * (t2 - t1);
      }
      ans = max(ans, t);
    }
  printf("%I64d\n", ans);
  return 0;
}
