#include<iostream>
#include<vector>
using namespace std;

int mian(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  
  sort(v.begin(), v.end());
  
  int a, b;
  a = v[0];
  b = v[v.size()-1];
  
  int num = 0;
  int i = 1;
  int j = 0;
  while(true){
    num = b*i-j
    if(num % a == a-1){
      break;
    }
    else if(num % b != 0){
      j--;
    }
    else {
      i++;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += num % v[i];
  }
  cout << ans << endl;
}