#include <bits/stdc++.h>
using namespace std;
int a[3005];
int shu(int m, int n);
int main() {
  int n;
  long long x;
  long long sum;
  long long ans;
  while (scanf("%d", &n) != EOF) {
    ans = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    x = a[0];
    long long t = 1;
    while (t != n) {
      x = x * a[t] / shu(x, a[t]);
      t++;
      if (t >= n) break;
    }
    for (int i = 0; i < x; i++) {
      sum = 0;
      for (int j = 0; j < n; j++) {
        sum += i % a[j];
      }
      ans = max(ans, sum);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
int shu(int m, int n) {
  int temp;
  int r;
  if (m < n) {
    temp = m;
    m = n;
    n = temp;
  }
  while (r = m % n, r != 0) {
    m = n;
    n = r;
  }
  return n;
}
