#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T, typename second>
T expo(T b, second e, const T &m) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b) % m, e >> 1, m)
                      : (b * expo((b * b) % m, e >> 1, m)) % m;
}
template <typename T, typename second>
T expo(T b, second e) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b), e >> 1) : (b * expo((b * b), e >> 1));
}
template <typename T, typename second>
T modinv(T a, second mod) {
  return expo(a, mod - 2, mod);
}
template <class T, class second>
std::ostream &operator<<(std::ostream &os, const std::pair<T, second> &t) {
  os << "(" << t.first << ", " << t.second << ")";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &t) {
  os << "[";
  for (__typeof(t.begin()) it = t.begin(); it != t.end(); it++) {
    if (it != t.begin()) os << ", ";
    os << *it;
  }
  os << "]";
  return os;
}
template <typename T>
void scanint(T &x) {
  T c = getchar();
  while (((c < 48) || (c > 57)) && (c != '-')) c = getchar();
  bool neg = false;
  if (c == '-') neg = true;
  x = 0;
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x * 10) + (c - 48);
  if (neg) x = -x;
}
const int MAXN = 2e5 + 3;
int n, arr[MAXN];
long long freq[MAXN];
bool vis[MAXN];
long long ans[MAXN];
int main() {
  scanint(n);
  for (int i = 1; i <= n; i++) scanint(arr[i]), freq[arr[i]]++;
  if (freq[1]) {
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      sum += (long long)arr[i];
    }
    printf("%lld\n", sum);
    return 0;
  }
  for (int i = 1; i < MAXN; i++) {
    freq[i] = freq[i - 1] + freq[i];
  }
  for (long long al = 1; al < MAXN; al++) {
    for (long long v = al; v < MAXN; v += al) {
      long long temp =
          (freq[min(v + al - 1, MAXN - 1ll)] - freq[v - 1]) * (v / al) * al;
      ans[al] += temp;
    }
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    res = max(res, ans[arr[i]]);
  }
  printf("%I64d\n", res);
  return 0;
}
