#include <bits/stdc++.h>
using namespace std;
bool vis[200100];
long long tmp, ans;
int arr[200100], ar[200100], mx;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    ar[arr[i]]++;
    mx = max(mx, arr[i]);
  }
  for (int i = 0; i < (mx + 10); i++) {
    ar[i] += ar[i - 1];
  }
  for (int i = 0; i < n; i++) {
    tmp = 0;
    int j;
    if (vis[arr[i]]) continue;
    vis[arr[i]] = true;
    for (j = 1; (j * arr[i]) <= mx; j++) {
      tmp += (1LL * ((j - 1) * arr[i]) *
              (ar[(j * arr[i]) - 1] - ar[((j - 1) * arr[i]) - 1]));
    }
    tmp +=
        (1LL * ((j - 1) * arr[i]) * (ar[mx + 5] - ar[((j - 1) * arr[i]) - 1]));
    ans = max(ans, tmp);
  }
  printf("%lld\n", ans);
  return 0;
}
