#include <bits/stdc++.h>
using namespace std;
inline void print(char pt) { printf("%c\n", pt); }
inline void print(int pt) { printf("%d\n", pt); }
inline void print(long long pt) { printf("%I64d\n", pt); }
inline void print(double pt) { printf("%.20f\n", pt); }
inline void print(char pt[]) { printf("%s\n", pt); }
inline void print() { printf("\n"); }
inline int scan(int &pt) { return scanf("%d", &pt); }
inline int scan(char &pt) { return scanf("%c", &pt); }
inline int scan(long long &pt) { return scanf("%I64d", &pt); }
inline int scan(double &pt) { return scanf("%lf", &pt); }
inline int scan(char pt[]) { return scanf("%s", pt); }
long long moda = 109098827479487ll;
using namespace std;
int n, k, m;
char stra[1000];
int a[300000];
int c[300000];
int main() {
  scan(n);
  int maxai = 0;
  long long sums = 0;
  for (int i = 0; i < n; i++) {
    scan(a[i]);
    sums += a[i];
    c[a[i]]++;
    maxai = max(a[i], maxai);
  }
  int maxn = min(maxai + 1, 200001);
  for (int i = 1; i <= maxn; i++) {
    c[i] += c[i - 1];
  }
  sort(a, a + n);
  long long suma = 0;
  long long maxa = 0;
  for (int i = 0; i < n; i++) {
    if (suma >= sums - maxa) break;
    suma += a[i];
    if (i && a[i] == a[i] - 1) {
      continue;
    }
    long long nowa = 0;
    for (int j = 1, tj = a[i];; j++, tj += a[i]) {
      if (tj + a[i] - 1 >= maxn) {
        nowa += 1ll * j * (c[maxn] - c[tj - 1]);
        break;
      }
      nowa += 1ll * j * (c[tj + a[i] - 1] - c[tj - 1]);
    }
    nowa *= a[i];
    maxa = max(maxa, nowa);
  }
  print(maxa);
  return 0;
}
