#include <bits/stdc++.h>
using namespace std;
int N, M = 200001;
long long arr[500000];
long long no[500000];
long long ans;
long long range(long long a, long long b) {
  if (a == 0ll) {
    return no[b];
  } else {
    return no[b] - no[a - 1];
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  if (fopen("cf731f.in", "r")) {
    freopen("cf731f.in", "r", stdin);
    freopen("cf731f.out", "w", stdout);
  }
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
    no[arr[i]]++;
  }
  sort(arr, arr + N);
  for (int i = 1; i < 500000; i++) {
    no[i] += no[i - 1];
  }
  for (int i = 0; i < N; i++) {
    if (arr[i] == arr[i + 1]) {
      continue;
    }
    long long temp = 0ll;
    for (long long j = 0; j < M; j += arr[i]) {
      temp += (range(j, j + arr[i] - 1)) * j;
    }
    ans = max(ans, temp);
  }
  cout << ans << '\n';
  return 0;
}
