#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int a[n], num[100000] = {};
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 1; i <= 100000; i++) {
    long long sum2 = 0;
    for (int j = 0; j < n; j++) {
      sum2 += (num[j] % a[j]);
      num[j] = ((num[j] + 1) % a[j]);
    }
    sum = max(sum, sum2);
  }
  cout << sum << endl;
}
