#include <bits/stdc++.h>
const int upload = 50000000;
int a[3001];
int n;
long long f(int m) {
  long long x = 0;
  for (int i = 1; i <= n; i++) {
    x += (m % a[i]);
  }
  return x;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  long long ans = -1;
  for (int i = 1; i <= upload / n + 1; i++) {
    ans = std::max(ans, f(i));
  }
  printf("%d", ans);
  return 0;
}
