#include <bits/stdc++.h>
using namespace std;
void check_array(int*, int);
int main() {
  int N;
  cin >> N;
  int* integer = new int[N];
  for (int i = 0; i < N; i++) {
    cin >> integer[i];
  }
  sort(integer, integer + N);
  int min_range = integer[0];
  int max_range = 100000;
  int answer = 0;
  for (int num_divided = 2147483647; num_divided > min_range + 1;
       num_divided--) {
    int tmp = 0;
    for (int i = 0; i < N; i++) {
      tmp += num_divided % integer[i];
    }
    if (answer < tmp) answer = tmp;
  }
  cout << answer << endl;
  delete[] integer;
  return 0;
}
void check_array(int* array, int array_size) {
  cout << "配列の中身" << endl;
  for (int i = 0; i < array_size; i++) {
    cout << array[i] << endl;
  }
}
