#include <bits/stdc++.h>
using namespace std;
struct Fast {
  Fast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
template <typename T>
inline size_t maxElement(T beginIt, T endIt) {
  return max_element(beginIt, endIt);
}
template <typename T>
inline size_t minElement(T beginIt, T endIt) {
  return min_element(beginIt, endIt);
}
template <typename T>
inline size_t maxIndex(T beginIt, T endIt) {
  return distance(beginIt, *max_element(beginIt, endIt));
}
template <typename T>
inline size_t minIndex(T beginIt, T endIt) {
  return distance(beginIt, *min_element(beginIt, endIt));
}
template <typename T>
inline int sum(T beginIt, T endIt) {
  return accumulate(beginIt, endIt, 0);
}
template <typename T>
inline int mean(T beginIt, T endIt) {
  return sum(beginIt, endIt) / distance(beginIt, endIt);
}
template <typename T>
inline void debug(T x) {
  cerr << x << " "
       << "(L:" << 12 << ")" << endl;
}
signed main(void) {
  int num;
  num = 0;
  int N;
  array<int, 3000> A;
  string S;
  array<int, 3000> B;
  int tmpMax = 1;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    tmpMax = tmpMax * A[i];
  }
  for (int m = 0; m < tmpMax; ++m) {
    int tmp = 0;
    for (int i = 0; i < N; ++i) {
      tmp += m % A[i];
    }
    num = max(tmp, num);
  }
  cout << num << endl;
  return 0;
}
