#include <bits/stdc++.h>
using namespace std;
void err() {}
template <typename T, typename... Args>
void err(T a, Args... args) {
  cout << a << ' ';
  err(args...);
}
template <class T>
void test(T a) {
  cout << a << endl;
}
template <class T, class T2>
void test(T a, T2 b) {
  cout << a << " " << b << endl;
}
template <class T, class T2, class T3>
void test(T a, T2 b, T3 c) {
  cout << a << " " << b << " " << c << endl;
}
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int mod = 998244353;
const int N = 1e3 + 5;
vector<int> a;
void work() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  long long ans = 0;
  for (int i = 1; i <= (3e5); i++) {
    long long sum = 0;
    for (auto it : a) {
      sum += i % it;
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  work();
  return 0;
}
