#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int maxn = 212345;
int mxn = 200000;
int bit[maxn];
int cnt[maxn];
bool vis[maxn];
int Lowbit(int x) { return x & (-x); }
void Add(int x, int ad) {
  while (x <= mxn) {
    bit[x] += ad;
    x += Lowbit(x);
  }
}
int Sum(int x) {
  int ans = 0;
  while (x) {
    ans += bit[x];
    x -= Lowbit(x);
  }
  return ans;
}
long long solve(long long x) {
  long long ans = 0;
  for (int i = 1; x * i <= mxn; ++i) {
    vis[x * i] = 1;
    if (x * (i + 1) - 1 <= mxn) {
      ans += x * i * (Sum(x * (i + 1) - 1) - Sum(x * i - 1));
    } else {
      ans += x * i * (Sum(mxn) - Sum(x * i - 1));
    }
  }
  return ans;
}
int num[maxn];
int main() {
  int x, n;
  scanf("%d", &n);
  mxn = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &num[i]);
    cnt[num[i]]++;
    mxn = max(mxn, num[i]);
  }
  for (int i = 0; i < n; ++i) Add(num[i], 1);
  long long mx = 0;
  for (int i = 1; i <= 200000; ++i) {
    if (!cnt[i]) continue;
    if (vis[i]) continue;
    mx = max(mx, solve(i));
  }
  printf("%lld\n", mx);
  return 0;
}
