#include <bits/stdc++.h>
using namespace std;
int bai(int x, int y) {
  int xx = x, yy = y;
  while (x != y) {
    if (x > y)
      x -= y;
    else
      y -= x;
  }
  return xx / x * yy;
}
int main() {
  int n, a[3001], an, kotae = -1, mi = 100000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0)
      an = a[i];
    else
      an = bai(an, a[i]);
    mi = min(mi, a[i]);
  }
  for (int i = an - 1; i >= mi; i--) {
    int memo = 0;
    for (int j = 0; j < n; j++) {
      memo += i % a[j];
    }
    kotae = max(kotae, memo);
  }
  cout << kotae << endl;
  getchar();
  getchar();
  return 0;
}
