#include <bits/stdc++.h>
using namespace std;
vector<long long int> arr, arr2;
int main(void) {
  long long int n, maxi = 0, x;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> x;
    arr.push_back(x);
    maxi = max(maxi, x);
  }
  sort(arr.begin(), arr.end());
  arr2.push_back(arr[0]);
  for (long long int i = 1; i < n; i++) {
    if (arr[i] != arr[i - 1]) {
      arr2.push_back(arr[i]);
    }
  }
  long long int x1, x2, s, ans = 0, siz = arr2.size();
  for (long long int i = 0; i < siz; i++) {
    s = 0;
    for (long long int j = arr2[i], j2 = 0; j2 <= maxi;
         j += arr2[i], j2 += arr2[i]) {
      x1 = lower_bound(arr.begin(), arr.end(), j2) - arr.begin();
      x2 = upper_bound(arr.begin(), arr.end(), j - 1) - arr.begin() - 1;
      if (x1 <= x2) {
        s += ((x2 - x1 + 1) * j2);
      }
    }
    ans = max(ans, s);
  }
  cout << ans << "\n";
  return 0;
}
