#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  for (int &x : num) cin >> x;
  sort(num.begin(), num.end());
  long long ans = 0;
  int maxnum = num[num.size() - 1] - 1;
  while (ans < n * maxnum) {
    long long a = 0;
    for (int i = 0; i < n; i++) {
      a += maxnum % num[i];
    }
    ans = max(ans, a);
    maxnum--;
  }
  cout << ans << endl;
}
