#include <bits/stdc++.h>
using namespace std;
int num[200005];
int a[200005];
int main() {
  int n;
  scanf("%d", &n);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
    num[a[i]]++;
  }
  sort(a, a + n);
  for (int i = 1; i <= mx; i++) num[i] += num[i - 1];
  long long ans = 0;
  if (a[0] == 1) {
    long long ret = 0;
    for (int i = 0; i < n; i++) ret += a[i];
    printf("%lld\n", ret);
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (i > 0 && a[i] == a[i - 1]) continue;
    long long ret = 0;
    ;
    int tmp;
    for (int j = 1; j <= mx; j = tmp + 1) {
      if (j == 1)
        tmp = a[i] - 1;
      else
        tmp = min(mx, j + a[i] - 1);
      long long t = 1ll * (j / a[i]) * a[i] * (num[tmp] - num[j - 1]);
      ret += t;
    }
    ans = max(ans, ret);
  }
  printf("%lld\n", ans);
}
