#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n;
int a[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int tmp = 0;
    for (int j = 1; j <= n; j++) tmp += i % a[j];
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
}
