#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, k;
bool has_p[201000];
int p[201000];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
    has_p[p[i]] = 1;
  }
  sort(&p[1], &p[1 + n]);
  long long int ans = 0, now, max_ans = 0;
  int l, r;
  for (i = 1; i <= 201000; i++) {
    if (!has_p[i]) continue;
    l = lower_bound(&p[1], &p[1 + n], i) - p;
    ans = 0;
    for (j = 2; i * j < 201000; j++) {
      r = lower_bound(&p[1], &p[1 + n], i * j) - p;
      now = i * (j - 1);
      now *= r - l;
      ans += now;
      l = r;
    }
    now = i * (j - 1);
    now *= n + 1 - l;
    ans += now;
    if (ans > max_ans) max_ans = ans;
  }
  printf("%I64d\n", max_ans);
  return 0;
}
