#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	int ans=INT_MAX;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	///if(arr[i]==1)cnt_one++;
	  }
	 //int result = arr[0];
    //for (int i = 1; i < n; i++)
      //  result = gcd(arr[i], result);
        //cout<<result;
   //if(result!=1)
    {
    //	cout<<acumsum;
    }
   //else
    {
    	//if(cnt_one==0)cout<<acumsum;
    	//else
    	{  //cout<<1;
    		sort(arr,arr+n);

    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{  //cout<<j<<endl;

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					/*for(int i=0;i<n;i++)
    					  cout<<arr[i]<<" ";
    					  cout<<endl;*/
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];

    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;
    					 arr[j]=prevj;

    					arr[i]*=divisors[k];
    					arr[j]=arr[j]/divisors[k];
    					//cout<<arr[i]<<" "<<arr[j]<<endl;;

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}

    					arr[i]=previ;
    				    arr[j]=prevj;
    				    j--;
    				    //cout<<j<<endl;

    				}

    					//return 0;

    		}

    	}
    }
    if(ans>acumsum)
      ans=acumsum;
    cout<<ans;

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int getDivisors(int n)
{
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            return i;
        }
    }
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	long long  acumsum=0;
	long long  cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }

    {
    	if(cnt_one==0)cout<<acumsum;
    	else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					int divisor=getDivisors(arr[j]);
    					//cout<<divisor;
    					arr[i]*=min(divisor,arr[j]/divisor);
    					arr[j]=max(divisor,arr[j]/divisor);
    					break;
    				}

    		}
    		long long  sum=0;
    		for(int i=0;i<n;i++)
    		   sum+=arr[i];
    		   cout<<sum;
    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int getDivisors(int n)
{
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            return i;
        }
    }
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	long long  acumsum=0;
	long long  cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }
	 int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
        //cout<<result;
    if(result!=1)
    {
    	cout<<acumsum;
    }
     else
    {
    	if(cnt_one==0)cout<<acumsum;
    	else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					int divisor=getDivisors(arr[j]);
    					//cout<<divisor;
    					arr[i]*=min(divisor,arr[j]/divisor);
    					arr[j]=max(divisor,arr[j]/divisor);
    					break;
    				}

    		}
    		long long  sum=0;
    		for(int i=0;i<n;i++)
    		   sum+=arr[i];
    		   cout<<sum;
    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int getDivisors(int n)
{
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            return i;
        }
    }
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	long long  acumsum=0;
	long long  cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }

    {
    	//if(cnt_one==0)cout<<acumsum;
    	//else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					int divisor=getDivisors(arr[j]);
    					//cout<<divisor;
    					arr[i]*=min(divisor,arr[j]/divisor);
    					arr[j]=max(divisor,arr[j]/divisor);
    					break;
    				}

    		}
    		long long  sum=0;
    		for(int i=0;i<n;i++)
    		   sum+=arr[i];
    		   cout<<sum;
    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	///if(arr[i]==1)cnt_one++;
	  }
	 //int result = arr[0];
    //for (int i = 1; i < n; i++)
      //  result = gcd(arr[i], result);
        //cout<<result;
   //if(result!=1)
    {
    //	cout<<acumsum;
    }
   //else
    {
    	//if(cnt_one==0)cout<<acumsum;
    	//else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		int ans=INT_MAX;
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				//if(isPrime(arr[j]))
    				  //j--;
    				//else
    				{  //cout<<arr[j];
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];

    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;
    					 //cout<<min(divisors[k],arr[j]/divisors[k])<<" "<<max(divisors[k],arr[j]/divisors[k])<<endl;
    					arr[i]*=min(divisors[k],arr[j]/divisors[k]);
    					arr[j]=max(divisors[k],arr[j]/divisors[k]);
    					//cout<<arr[i]<<" "<<arr[j];

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}
    					if(ans>acumsum)
    					  ans=acumsum;
    					cout<<ans;
    					return 0;
    				}

    		}

    	}
    }
    cout<<acumsum;

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	///if(arr[i]==1)cnt_one++;
	  }
	 //int result = arr[0];
    //for (int i = 1; i < n; i++)
      //  result = gcd(arr[i], result);
        //cout<<result;
   //if(result!=1)
    {
    //	cout<<acumsum;
    }
   //else
    {
    	//if(cnt_one==0)cout<<acumsum;
    	//else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		int ans=INT_MAX;
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{  //cout<<arr[j];
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];

    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;
    					 arr[j]=prevj;

    					arr[i]*=divisors[k];
    					arr[j]=arr[j]/divisors[k];
    					//cout<<arr[i]<<" "<<arr[j];

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}
    					if(ans>acumsum)
    					  ans=acumsum;
    					cout<<ans;
    					return 0;
    				}

    		}

    	}
    }
    cout<<acumsum;

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n, accmcnt = 0;
	cin >> n;
	vector < int > v(n);
	for(int i = 0;i < n;++i){
		cin >> v[i];
		accmcnt += v[i];
	}
	int ans = accmcnt;
	sort(v.begin(), v.end());
	for(int i = n-1;i > 0;--i){
		for(int j = 2;j <= v[i];++j){
			if(v[i] % j == 0){

				ans = min(ans, accmcnt - (v[i]-v[i]/j) + (v[0]*j)-v[0]);
			}
		}
	}
	cout << ans << endl;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }
	 int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
        //cout<<result;
   // if(result!=1)
    {
    //	cout<<acumsum;
    }
    // else
    {
    //	if(cnt_one==0)cout<<acumsum;
    //	else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];
    					int ans=INT_MAX;
    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;

    					arr[i]*=min(divisors[k],arr[j]/divisors[k]);
    					arr[j]=max(divisors[k],arr[j]/divisors[k]);

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}
    					if(ans>acumsum)
    					  ans=acumsum;
    					cout<<ans;
    					break;
    				}

    		}

    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }
	 int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
        //cout<<result;
    if(result!=1)
    {
    	cout<<acumsum;
    }
     else
    {
    	if(cnt_one==0)cout<<acumsum;
    	else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];
    					int ans=INT_MAX;
    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;

    					arr[i]*=min(divisors[k],arr[j]/divisors[k]);
    					arr[j]=max(divisors[k],arr[j]/divisors[k]);

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}
    					cout<<ans;
    					break;
    				}

    		}

    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	///if(arr[i]==1)cnt_one++;
	  }
	 //int result = arr[0];
    //for (int i = 1; i < n; i++)
      //  result = gcd(arr[i], result);
        //cout<<result;
   //if(result!=1)
    {
    //	cout<<acumsum;
    }
   //else
    {
    	//if(cnt_one==0)cout<<acumsum;
    	//else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		int ans=INT_MAX;
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{  //cout<<arr[j];
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];

    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;
    					 //cout<<min(divisors[k],arr[j]/divisors[k])<<" "<<max(divisors[k],arr[j]/divisors[k])<<endl;
    					arr[i]*=min(divisors[k],arr[j]/divisors[k]);
    					arr[j]=max(divisors[k],arr[j]/divisors[k]);
    					//cout<<arr[i]<<" "<<arr[j];

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}
    					if(ans>acumsum)
    					  ans=acumsum;
    					cout<<ans;
    					break;
    				}

    		}

    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int getDivisors(int n)
{
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            return i;
        }
    }
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	long long  acumsum=0;
	long long  cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }

    {
    	if(cnt_one==0)cout<<acumsum;
    	else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				//else
    				{
    					int divisor=getDivisors(arr[j]);
    					//cout<<divisor;
    					arr[i]*=min(divisor,arr[j]/divisor);
    					arr[j]=max(divisor,arr[j]/divisor);
    					break;
    				}

    		}
    		long long  sum=0;
    		for(int i=0;i<n;i++)
    		   sum+=arr[i];
    		   cout<<sum;
    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }
	 int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
        //cout<<result;
   // if(result!=1)
    {
    //	cout<<acumsum;
    }
     else
    {
    //	if(cnt_one==0)cout<<acumsum;
    //	else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];
    					int ans=INT_MAX;
    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;

    					arr[i]*=min(divisors[k],arr[j]/divisors[k]);
    					arr[j]=max(divisors[k],arr[j]/divisors[k]);

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}
    					if(ans>acumsum)
    					  ans=acumsum;
    					cout<<ans;
    					break;
    				}

    		}

    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int getDivisors(int n)
{
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            return i;
        }
    }
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }
	 int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
        //cout<<result;
    if(result!=1)
    {
    	cout<<acumsum;
    }
     else
    {
    	//if(cnt_one==0)cout<<acumsum;
    	//else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					int divisor=getDivisors(arr[j]);
    					//cout<<divisor;
    					arr[i]*=min(divisor,arr[j]/divisor);
    					arr[j]=max(divisor,arr[j]/divisor);
    					break;
    				}

    		}
    		int sum=0;
    		for(int i=0;i<n;i++)
    		   sum+=arr[i];
    		   cout<<sum;
    	}
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	int acumsum=0;
	int cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	///if(arr[i]==1)cnt_one++;
	  }
	 //int result = arr[0];
    //for (int i = 1; i < n; i++)
      //  result = gcd(arr[i], result);
        //cout<<result;
   //if(result!=1)
    {
    //	cout<<acumsum;
    }
   //else
    {
    	//if(cnt_one==0)cout<<acumsum;
    	//else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		int ans=INT_MAX;
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{  //cout<<arr[j];
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];

    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;

    					arr[i]*=divisors[k];
    					arr[j]=arr[j]/divisors[k];
    					//cout<<arr[i]<<" "<<arr[j];

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}
    					if(ans>acumsum)
    					  ans=acumsum;
    					cout<<ans;
    					return 0;
    				}

    		}

    	}
    }
    cout<<acumsum;

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i < n; i++)
        if (n % i == 0)
            return false;

    return true;
}

int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
vector<int> getDivisors(int n)
{  vector<int>divisors;
    // Note that this loop runs till square root
    for (int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            divisors.push_back(i);
        }
    }
    return divisors;
}

int main() {

	int n;
	cin>>n;
	int arr[n];
	long long  acumsum=0;
	long long  cnt_one=0;
	for(int i=0;i<n;i++)
	  {
	  	cin>>arr[i];
	  	acumsum+=arr[i];
	  	if(arr[i]==1)cnt_one++;
	  }

    {
    	if(cnt_one==0)cout<<acumsum;
    	else
    	{  //cout<<1;
    		sort(arr,arr+n);
    		for(int i=0,j=n-1;i<n&&j>=0&&i!=j;)
    		{

    				if(isPrime(arr[j]))
    				  j--;
    				else
    				{
    					vector<int>divisors =getDivisors(arr[j]);
    					int previ=arr[i];
    					int prevj=arr[j];
    					int ans=INT_MAX;
    					for(int k=0;k<divisors.size();k++)
    					{arr[i]=previ;

    					arr[i]*=min(divisors[k],arr[j]/divisors[k]);
    					arr[j]=max(divisors[k],arr[j]/divisors[k]);

    					int  sum=0;

			    		for(int l=0;l<n;l++)
			    		   sum+=arr[l];
			    		   //cout<<sum;
			    		   ans=min(ans,sum);
    					}
    					cout<<ans;
    					break;
    				}

    		}

    	}
    }

	return 0;
}


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n, sum = 0, count = 0, m, flag = 0, ans = 1e18, k = 0;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i], k = max(k, v[i]);
    for(int i = 2; i <= k / 2; i++)
    {
        multiset<int> s;
        count = 0;
        for(int j = 0; j < n; j++)
            s.insert(v[j]);
        for(auto it = s.rbegin(); it != s.rend(); )
        {
            if((*it) % i == 0)
            {
                auto jt = it;
                jt++;
                s.insert((*it) / i);
                s.erase(s.find(*it));
                s.insert(*(s.begin()) * i);
                s.erase(s.begin());
                it = jt;
            }
            else
            {
                it++;
            }
        }
        for(auto it : s)
        {
            count += it;
        }
        //cout << count << endl;
        ans = min(ans, count);
    }
    cout << ans;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n, sum = 0, count = 0, m, flag = 0, ans = 0, k = 0;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        k = max(k, v[i]);
        ans += v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 0 ; i < n; i++)
    {
        for(int j = 2; j <= v[i] / 2; j++)
        {
            if(v[i] % j == 0)
            {
                ans = min(ans, ans - v[i] - v[0] + v[0] * j + v[i] / j);
            }
        }
    }
    cout << ans;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n, sum = 0, count = 0, m, flag = 0, ans = 0, k = 0;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        k += v[i];
    }
    ans = k;
    sort(v.begin(), v.end());
    for(int i = 0 ; i < n; i++)
    {
        for(int j = 2; j <= v[i] / 2; j++)
        {
            if(v[i] % j == 0)
            {
                ans = min(ans, k - v[i] - v[0] + (v[0] * j) + (v[i] / j));
            }
        }
    }
    cout << ans;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n, sum = 0, count = 0, m, flag = 0, ans = 0, k = 0;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        k = max(k, v[i]);
        ans += v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 2; i <= k / 2; i++)
    {
        vi c = v;
        ll tempAns = 0;
        count = 0;
        for(int j = 0; j < n; j++)
        {
            if(c[j] % i == 0)
            {
                c[j] /= i;
                count ++;
            }
        }
        for(int j = 0; j < n; j++)
        {
            if(j < count)
                tempAns += c[j] * i;
            else
                tempAns += c[j];
        }
        ans = min(tempAns, ans);
    }
    cout << ans;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n, sum = 0, count = 0, m, flag = 0, ans = 0, k = 0;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i], k = max(k, v[i]), ans += v[i];
    sort(v.begin(), v.end());
    for(int i = 2; i <= k / 2; i++)
    {
        ll tempAns = 0;
        count = 0;
        for(int j = 0; j < n; j++)
        {
            if(v[j] % i == 0)
            {
                count ++;
            }
        }
        for(int j = 0; j < count; j++)
            tempAns += (v[j] % i ? v[j] * i : v[j]);
        for(int j = count; j < n; j++)
            tempAns += (v[j] % i ? v[j] : v[j] / i);
        ans = min(tempAns, ans);
    }
    cout << ans;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n, sum = 0, count = 0, m, flag = 0, ans = 0, k = 0;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        k = max(k, v[i]);
        ans += v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 2; i <= 100; i++)
    {
        ll tempAns = 0;
        count = 0;
        for(int j = 0; j < n; j++)
        {
            if(v[j] % i == 0)
            {
                count ++;
            }
        }
        for(int j = 0; j < count; j++)
        {
            tempAns += (v[j] % i ? v[j] * i : v[j]);
        }
        for(int j = count; j < n; j++)
        {
            tempAns += (v[j] % i ? v[j] : v[j] / i);
        }
        ans = min(tempAns, ans);
    }
    cout << ans;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n, sum = 0, count = 0, m, flag = 0, ans = 0, k = 0;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        k += v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 0 ; i < n; i++)
    {
        for(int j = 2; j <= v[i] / 2; j++)
        {
            if(v[i] % j == 0)
            {
                ans = min(ans, k - v[i] - v[0] + (v[0] * j) + (v[i] / j));
            }
        }
    }
    cout << ans;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


// <3 Appy!
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
typedef vector<long long int> vi;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll n, sum = 0, count = 0, m, flag = 0, ans = 1e18, k = 0;
    cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i], k = max(k, v[i]);
    for(int i = 2; i <= k / 2; i++)
    {
        multiset<pair<int, int> > s;
        count = 0;
        for(int j = 0; j < n; j++)
            s.insert({v[j], j});
        int has[(int)6e4] = {0};
        for(auto it = s.rbegin(); it != s.rend(); )
        {
            //cout << (it->first);
            if(has[(it -> second)] == 1)
            {
                it++;
                continue;
            }
            if(((it -> first)) % i == 0)
            {
                has[(it -> second)] = 1;
                auto jt = it;
                jt++;
                s.insert({(it -> first) / i, (it -> second)});
                s.erase(s.find(*it));
                s.insert({(s.begin() -> first) * i, (s.begin() -> second)});
                s.erase(s.begin());
                it = jt;
            }
            else
            {
                it++;
            }
        }
        for(auto it : s)
        {
            count += it.first;
        }
        //cout << count << endl;
        ans = min(ans, count);
    }
    cout << ans;
    return 0;
}

/* freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 */


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	multiset<int>tr;
	multiset<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		tr.insert(a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	for(int i=0;i<n;i++){
		if(a[i]>2){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]/j>mmin)
					{
						sum -= (a[i]/j-mmin)*(j-1);
						tr.erase(mmin);
						mmin = *tr.begin();
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	int tmp = 0;
	for(int i=0;i<n;i++){
		if(a[i]>2){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]*(j-1)/j>mmin*(j-1))
					{
						sum -= (a[i]/j-mmin)*(j-1);
						for(int i=tmp+1;mmin>a[i];i++)
							mmin = a[i],tmp=i;
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	int tmp = 0;
	for(int i=0;i<n;i++){
		if(a[i]>2){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]/j>mmin)
					{
						sum -= (a[i]/j-mmin)*(j-1);
						mmin = min(a[i]/j,mmin*j);
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	set<int>tr;
	set<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		tr.insert(a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	int tmp = 0;
	for(int i=0;i<n;i++){
		if(a[i]>1){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]/j>a[0])
					{
						sum -= (a[i]/j-a[0])*(j-1);
						tmp++;
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	int tmp = 0;
	for(int i=0;i<n;i++){
		if(a[i]>2){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]/j>mmin)
					{
						sum -= (a[i]/j-mmin)*(j-1);
						a[i] /= j;
						for(int z=tmp+1;mmin>a[z];z++)
							mmin = a[z],tmp=z;
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	set<int>tr;
	set<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		tr.insert(a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	int tmp = 1;
	for(int i=0;i<n;i++){
		if(a[i]>1){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]/j>mmin)
					{
						sum -= (a[i]/j-mmin)*(j-1);
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	for(int i=0;i<n;i++){
		if(a[i]>2){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]*(j-1)/j>mmin*(j-1))
					{
						sum -= (a[i]/j-mmin)*(j-1);
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	set<int>tr;
	set<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		tr.insert(a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	int tmp = 0;
	for(int i=0;i<n;i++){
		if(a[i]>1){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]/j>a[tmp])
					{
						sum -= (a[i]/j-a[tmp])*(j-1);
						tmp++;
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int a[50005];
int main()
{
	scanf("%d",&n);
	int sum=0;
//	set<int>tr;
//	set<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	int ans = sum;
	int mmin = a[0];
	for(int i=0;i<n;i++){
		for(int j=1;j<=100;j++)
		{
			if(a[i]%j==0)
			{
				ans = min(ans,sum-mmin-a[i]+mmin*j+a[i]/j);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int a[50005];
int main()
{
	scanf("%d",&n);
	int sum=0;
//	set<int>tr;
//	set<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	int ans = sum;
	int mmin = a[0];
	for(int i=0;i<n;i++){
		for(int j=1;j<=100;j++)
		{
			if(a[i]%j==0)
			{
				sum = min(ans,sum-mmin-a[i]+mmin*j+a[i]/j);
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	set<int>tr;
	set<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		tr.insert(a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	int tmp = 1;
	for(int i=0;i<n;i++){
		if(a[i]>2){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]/j>mmin)
					{
						sum -= (a[i]/j-mmin)*(j-1);
						if(s[i]/j>a[tmp]){
							mmin = a[tmp];
						}
						else{
							mmin = a[i]/j
							tmp++;
						}
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
long long a[50005];
int main()
{
	scanf("%d",&n);
	long long sum=0;
	set<int>tr;
	set<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		tr.insert(a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	long long mmin = a[0];
	int tmp = 1;
	for(int i=0;i<n;i++){
		if(a[i]>2){
			for(int j=2;j*j<=a[i];j++){
				if(a[i]%j==0){
					if(a[i]/j>mmin)
					{
						sum -= (a[i]/j-mmin)*(j-1);
						if(a[i]/j>a[tmp]){
							mmin = a[tmp];
						}
						else{
							mmin = a[i]/j;
							tmp++;
						}
					}
				}

			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int a[50005];
int main()
{
	scanf("%d",&n);
	int sum=0;
//	set<int>tr;
//	set<int>::iterator it;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
	}
	sort(a,a+n);
	int ans = sum;
	int mmin = a[0];
	for(int i=0;i<n;i++){
		for(int j=1;j<=100;j++)
		{
			if(a[i]%j==0)
			{
				ans = min(ans,sum-mmin-a[i]+mmin*j+a[i]/j);
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// when we want to insert same element multiple times into pbds
// typedef tree<pair<int,int>,null_type,less<pair<int,int > >,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

bool double_compare(double a, double b, double epsilon = 0.001)
{
    return std::abs(a - b) < epsilon;
}
int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){

    int ans=1;
    while(b){

        if(b&1ll){

            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }

    return ans;
}
int inverse(int a,int mod1){

    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////

signed main()
{
    int n;
    cin>>n;

    int a[n+1],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }

    sort(a,a+n);

    int div=-1,ss=sum,x=-1,number=-1;
    bool yy=false;
    for(int i=n-1;i>=0;i--){

        for(int j=2;j*j<=a[i];j++){
            if(a[i]%j==0 && a[i]/j>div){
                div=a[i]/j;
                ss-=a[i];
                ss+=div;
                x=j;
                yy=true;
                number=a[i];
            }
        }
    }

    bool yo=false;
    int num=INT_MAX;
    for(int i=0;i<n;i++){
        if(a[i]<div && num>(ss-a[i]+a[i]*x) && number!=a[i]){
            ss+=a[i]*x;
            yo=true;
            ss-=a[i];
            num=ss;
        }
    }

    if(yy && yo && ss<sum){
        cout<<ss<<endl;
    }
    else{
        cout<<sum<<endl;
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// when we want to insert same element multiple times into pbds
// typedef tree<pair<int,int>,null_type,less<pair<int,int > >,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

bool double_compare(double a, double b, double epsilon = 0.001)
{
    return std::abs(a - b) < epsilon;
}
int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){

    int ans=1;
    while(b){

        if(b&1ll){

            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }

    return ans;
}
int inverse(int a,int mod1){

    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////

signed main()
{
    int n;
    cin>>n;

    int a[n+1],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }

    sort(a,a+n);

    int div=-1,ss=sum,x=-1;
    bool yy=false;
    for(int i=n-1;i>=0;i--){

        for(int j=2;j*j<=a[i];j++){
            if(a[i]%j==0 && a[i]/j>div){
                div=a[i]/j;
                ss-=a[i];
                ss+=div;
                x=j;
                yy=true;
            }
        }
    }

    bool yo=false;
    for(int i=0;i<n;i++){
        if(a[i]<div){
            ss+=a[i]*x;
            yo=true;
            ss-=a[i];
            break;
        }
    }

    if(yy && yo && ss<sum){
        cout<<ss<<endl;
    }
    else{
        cout<<sum<<endl;
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// when we want to insert same element multiple times into pbds
// typedef tree<pair<int,int>,null_type,less<pair<int,int > >,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

bool double_compare(double a, double b, double epsilon = 0.001)
{
    return std::abs(a - b) < epsilon;
}
int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){

    int ans=1;
    while(b){

        if(b&1ll){

            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }

    return ans;
}
int inverse(int a,int mod1){

    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////

signed main()
{
    int n;
    cin>>n;

    int a[n+1],sum=0,mn=INT_MAX;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        mn=min(mn,a[i]);
    }

    int ans=sum;
    for(int i=0;i<n;i++){

        for(int x=1;x<=a[i];x++){
            if(a[i]%x==0){

                int curr=sum-a[i]+a[i]/x+mn*x-mn;
                ans=min(ans,curr);
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// when we want to insert same element multiple times into pbds
// typedef tree<pair<int,int>,null_type,less<pair<int,int > >,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

bool double_compare(double a, double b, double epsilon = 0.001)
{
    return std::abs(a - b) < epsilon;
}
int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){

    int ans=1;
    while(b){

        if(b&1ll){

            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }

    return ans;
}
int inverse(int a,int mod1){

    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////

signed main()
{
    int n;
    cin>>n;

    int a[n+1],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }

    sort(a,a+n);

    int div=-1,ss=sum,x=-1;
    bool yy=false;
    for(int i=n-1;i>=0;i--){

        for(int j=2;j*j<=a[i];j++){
            if(a[i]%j==0){
                div=a[i]/j;
                ss-=a[i];
                ss+=div;
                x=j;
                yy=true;
                break;
            }
        }
        if(div!=-1){
            break;
        }
    }

    bool yo=false;
    for(int i=0;i<n;i++){
        if(a[i]<div){
            ss-=a[i];
            ss+=a[i]*x;
            yo=true;
            break;
        }
    }

    if(yy && yo && ss<sum){
        cout<<ss<<endl;
    }
    else{
        cout<<sum<<endl;
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// when we want to insert same element multiple times into pbds
// typedef tree<pair<int,int>,null_type,less<pair<int,int > >,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

bool double_compare(double a, double b, double epsilon = 0.001)
{
    return std::abs(a - b) < epsilon;
}
int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){

    int ans=1;
    while(b){

        if(b&1ll){

            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }

    return ans;
}
int inverse(int a,int mod1){

    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////

signed main()
{
    int n;
    cin>>n;

    int a[n+1],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }

    sort(a,a+n);

    int div=-1,ss=sum,x=-1,number=-1;
    bool yy=false;
    for(int i=n-1;i>=0;i--){

        for(int j=2;j<=a[i];j++){
            if(a[i]%j==0 && a[i]/j>div){
                div=a[i]/j;
                ss-=a[i];
                ss+=div;
                x=j;
                yy=true;
                number=a[i];
            }
        }
    }

    bool yo=false;
    int num=INT_MAX;
    for(int i=0;i<n;i++){
        if(a[i]<div && num>(ss-a[i]+a[i]*x) && number!=a[i]){
            ss+=a[i]*x;
            yo=true;
            ss-=a[i];
            num=ss;
        }
    }

    if(yy && yo && ss<sum){
        cout<<ss<<endl;
    }
    else{
        cout<<sum<<endl;
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// when we want to insert same element multiple times into pbds
// typedef tree<pair<int,int>,null_type,less<pair<int,int > >,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

bool double_compare(double a, double b, double epsilon = 0.001)
{
    return std::abs(a - b) < epsilon;
}
int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){

    int ans=1;
    while(b){

        if(b&1ll){

            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }

    return ans;
}
int inverse(int a,int mod1){

    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////

signed main()
{
    int n;
    cin>>n;

    int a[n+1],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }

    sort(a,a+n);

    int div=-1,ss=sum,x=-1,number=-1;
    bool yy=false;
    for(int i=n-1;i>=0;i--){

        for(int j=1;j<=a[i];j++){
            if(a[i]%j==0 && a[i]/j>div){
                div=a[i]/j;
                ss-=a[i];
                ss+=div;
                x=j;
                yy=true;
                number=a[i];
            }
        }
    }

    bool yo=false;
    int num=INT_MAX;
    for(int i=0;i<n;i++){
        if(a[i]<div && num>(ss-a[i]+a[i]*x) && number!=a[i]){
            ss+=a[i]*x;
            yo=true;
            ss-=a[i];
            num=ss;
        }
    }

    if(yy && yo && ss<sum){
        cout<<ss<<endl;
    }
    else{
        cout<<sum<<endl;
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// when we want to insert same element multiple times into pbds
// typedef tree<pair<int,int>,null_type,less<pair<int,int > >,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

bool double_compare(double a, double b, double epsilon = 0.001)
{
    return std::abs(a - b) < epsilon;
}
int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){

    int ans=1;
    while(b){

        if(b&1ll){

            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }

    return ans;
}
int inverse(int a,int mod1){

    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////

signed main()
{
    int n;
    cin>>n;

    int a[n+1],sum=0,mn=INT_MAX;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        mn=min(mn,a[i]);
    }

    sort(a,a+n);

    int div=-1,ss=sum,x=-1,number=-1;
    bool yy=false;
    for(int i=n-1;i>=0;i--){

        for(int j=2;j<=a[i];j++){
            if(a[i]%j==0 && a[i]/j>div){
                div=a[i]/j;
                x=j;
                yy=true;
                number=a[i];
            }
        }
    }

    ss-=number;
    ss+=div;
    ss-=a[0];
    ss+=a[0]*x;

    bool yo=true;

    if(yy && yo && ss<sum){
        cout<<ss<<endl;
    }
    else{
        cout<<sum<<endl;
    }

    return 0;
}

/*

*/


// by VIDIT BHARDWAJ
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;

// when we want to insert same element multiple times into pbds
// typedef tree<pair<int,int>,null_type,less<pair<int,int > >,rb_tree_tag,tree_order_statistics_node_update> pbds;

#define int                     long long int
#define pb                      push_back
#define mk(arr,n,type)          type *arr=new type[n]; //mk(pos,n,vector<int>)
#define setbits(x)              __builtin_popcountll(x)
#define zerobits(x)             __builtin_ctzll(x)
#define ps(x,y)                 fixed<<setprecision(y)<<x // cout<<ps(1.255114,4)
#define tc(t)                   int t; cin>>t; while(t--)

const long long mod=1000000007;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;

bool double_compare(double a, double b, double epsilon = 0.001)
{
    return std::abs(a - b) < epsilon;
}
int lcm(int a,int b){
    return (a*b)/__gcd(a,b);
}
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6){
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}
// Fermat's little theorem
int pow(int a, unsigned int b,int mod1){

    int ans=1;
    while(b){

        if(b&1ll){

            ans*=a;
            ans%=mod1;
        }
        b/=2;
        a*=a;
        a%=mod1;
    }

    return ans;
}
int inverse(int a,int mod1){

    return pow(a,mod1-2,mod1);    // a^-1%p
}
///////////////////////////////////////////////////////////////////////////////////////////////////

signed main()
{
    int n;
    cin>>n;

    int a[n+1],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }

    sort(a,a+n);

    int div=-1,ss=sum,x=-1;
    bool yy=false;
    for(int i=n-1;i>=0;i--){

        for(int j=2;j*j<=a[i];j++){
            if(a[i]%j==0 && a[i]/j>div){
                div=a[i]/j;
                ss-=a[i];
                ss+=div;
                x=j;
                yy=true;
            }
        }
    }

    bool yo=false;
    int num=INT_MAX;
    for(int i=0;i<n;i++){
        if(a[i]<div && num>(ss-a[i]+a[i]*x)){
            ss+=a[i]*x;
            yo=true;
            ss-=a[i];
            num=ss;
        }
    }

    if(yy && yo && ss<sum){
        cout<<ss<<endl;
    }
    else{
        cout<<sum<<endl;
    }

    return 0;
}

/*

*/


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef unsigned long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
ll arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int v;
    scanf("%d", &n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &arr[i]);
        sum += arr[i];
    }
    sort(arr, arr + n);
    ll minn = 0;
    for (int i = n - 1; i >= 0; i--) {
        vector<int> factors;
        int k = arr[i];
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                factors.push_back(cnt * j);
            }
            if (k == 1) break;
        }
        for (auto f : factors) {
            minn = max(minn, -arr[0] * (f - 1) + (arr[i] - arr[i] / f));
            f = arr[i] / f;
            minn = max(minn, -arr[0] * (f - 1) + (arr[i] - arr[i] / f));
        }
    }
    printf("%lld\n", sum - minn);
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    ll sum = 0;
    map<int, int> ints;
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        sum += arr[i];
        ints[arr[i]]++;
    }
    int minn = 0;
    for (auto i : ints) {
        if (i.first == ints.begin()->first && i.second == 1) continue;
        vector<int> factors;
        int k = i.first;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                factors.push_back(cnt * j);
            }
            if (k == 1 || k < j) break;
        }
        if (k > 1) factors.push_back(k);
        for (auto f : factors) {
            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
            f = i.first / f;

            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
        }
    }
    printf("%d\n", sum - max(minn, 0));
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef unsigned long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
ll arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int v;
    scanf("%d", &n);
    ll sum = 0;
    set<ll> ints;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &arr[i]);
        sum += arr[i];
        ints.insert(arr[i]);
    }
    ll minn = 0;
    for (auto i : ints) {
        vector<ll> factors;
        int k = i;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                factors.push_back(cnt * j);
            }
            if (k == 1) break;
        }
        for (auto f : factors) {
            minn = max(minn, -*ints.begin() * (f - 1) + (i - i / f));
            f = i / f;
            minn = max(minn, -*ints.begin() * (f - 1) + (i - i / f));
        }
    }
    printf("%lld\n", sum - max(minn, 0LL));
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    ll sum = 0;
    map<int, int> ints;
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        sum += arr[i];
        ints[arr[i]]++;
    }
    int minn = 0;
    for (auto i : ints) {
        if (i.first == ints.begin()->first && i.second == 1) continue;
        vector<int> factors;
        int k = i.first;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                if (j * j == i.first) k /= j;
                factors.push_back(cnt * j);
            }
            if (k == 1 || k < j) break;
        }
        if (k > 1) factors.push_back(k);
        for (auto f : factors) {
            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
            f = i.first / f;

            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
        }
    }
    printf("%d\n", sum - max(minn, 0));
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    int sum = 0;
    map<int, int> ints;
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        sum += arr[i];
        ints[arr[i]]++;
    }
    int minn = 0;
    for (auto i : ints) {
        if (i.first == ints.begin()->first && i.second == 1) continue;
        vector<int> factors;
        int k = i.first;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                factors.push_back(cnt * j);
            }
            if (k == 1 || k < j) break;
        }
        for (auto f : factors) {
            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
            f = i.first / f;
            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
        }
    }
    printf("%d\n", sum - max(minn, 0));
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef unsigned long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
ll arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int v;
    scanf("%d", &n);
    ll sum = 0;
    set<ll> ints;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &arr[i]);
        sum += arr[i];
        ints.insert(arr[i]);
    }
    ll minn = 0;
    for (auto i : ints) {
        vector<ll> factors;
        int k = i;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                factors.push_back(cnt * j);
            }
            if (k == 1) break;
        }
        for (auto f : factors) {
            minn = max(minn, -*ints.begin() * (f - 1) + (i - i / f));
            f = i / f;
            minn = max(minn, -*ints.begin() * (f - 1) + (i - i / f));
        }
    }
    printf("%lld\n", sum - max(minn, 0LL);
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    ll sum = 0;
    map<int, int> ints;
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        sum += arr[i];
        ints[arr[i]]++;
    }
    int minn = 0;
    for (auto i : ints) {
        if (i.first == ints.begin()->first && i.second == 1) continue;
        vector<int> factors;
        int k = i.first;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                factors.push_back(cnt * j);
            }
            if (k == 1 || k < j) break;
        }
        for (auto f : factors) {
            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
            f = i.first / f;
            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
        }
    }
    printf("%d\n", sum - max(minn, 0));
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    ll sum = 0;
    map<int, int> ints;
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        sum += arr[i];
        ints[arr[i]]++;
    }
    int minn = 0;
    for (auto i : ints) {
        if (i.first == ints.begin()->first && i.second == 1) continue;
        vector<int> factors;
        int k = i.first;
        for (int j = 1; j <= k; j++) {
            if (k % j == 0) {
                factors.push_back(j);
            }
        }
        for (auto f : factors) {
            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
            f = i.first / f;

            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
        }
    }
    printf("%d\n", sum - max(minn, 0));
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    ll sum = 0;
    map<int, int> ints;
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        sum += arr[i];
        ints[arr[i]]++;
    }
    int minn = 0;
    for (auto i : ints) {
        if (i.first == ints.begin()->first && i.second == 1) continue;
        vector<int> factors;
        int k = i.first;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                if (j * j != i.first) factors.push_back(cnt * j);
            }
            if (k == 1 || k < j) break;
        }
        if (k > 1) factors.push_back(k);
        for (auto f : factors) {
            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
            f = i.first / f;

            minn = max(minn, -ints.begin()->first * (f - 1) +
                                 (i.first - i.first / (f)));
        }
    }
    printf("%d\n", sum - max(minn, 0));
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int v;
    scanf("%d", &n);
    int sum = 0;
    set<int> ints;
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        sum += arr[i];
        ints.insert(arr[i]);
    }
    int minn = 0;
    for (auto i : ints) {
        if (i == *ints.begin()) continue;
        vector<int> factors;
        int k = i;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                factors.push_back(cnt * j);
            }
            if (k == 1 || k < j) break;
        }
        for (auto f : factors) {
            minn = max(minn, -*ints.begin() * (f - 1) + (i - i / (f)));
            f = i / f;
            minn = max(minn, -*ints.begin() * (f - 1) + (i - i / (f)));
        }
    }
    printf("%d\n", sum - max(minn, 0));
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef long long ll;

const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.1415926;
const ll MOD = 1e9;

struct Edge {
    int to;
    int dis;
    Edge(int to, int dis) : to(to), dis(dis) {}
    bool operator<(const Edge& b) const { return this->dis > b.dis; }
};

struct Point {
    int x, y;
    Point() : x(0), y(0) {}
    Point(int x, int y) : x(x), y(y) {}
    bool operator<(const Point& b) const { return this->x < b.x; }
};

inline int read() {
    int X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}

int quickM(ll x, ll p, int mod) {
    if (mod == 0) return 1;
    x %= mod;
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}

void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

struct Food {
    ll a, c;
};
int n, m;
int CASE;
const int MAXN = 50005;
ll arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int v;
    scanf("%d", &n);
    ll sum = 0;
    set<ll> ints;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &arr[i]);
        sum += arr[i];
        ints.insert(arr[i]);
    }
    ll minn = 0;
    for (auto i : ints) {
        vector<ll> factors;
        int k = i;
        for (int j = 2; j * j <= k; j++) {
            int cnt = 0;
            while (k % j == 0) {
                k /= j;
                cnt++;
                factors.push_back(cnt * j);
            }
            if (k == 1) break;
        }
        for (auto f : factors) {
            minn = max(minn, -*ints.begin() * (f - 1) + (i - i / f));
            f = i / f;
            minn = max(minn, -*ints.begin() * (f - 1) + (i - i / f));
        }
    }
    printf("%lld\n", sum - max(minn, 0LL));
    return 0;
}


// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

vector<int> fact[105];
int a[5*(int)1e4+5];

int main() {
	IOS
	for(int i=1; i<=100; i++) {
		for(int j=2; j<=i; j++) {
			if(i%j==0) fact[i].push_back(j);
		}
	}
	long long sum = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	for(int i=0; i<n; i++) sum += a[i];
	for(int i=1; i<n; i++) {
			for(auto e : fact[a[0]]) {
				long long s = sum;
				s -= a[0] - (a[0]/e);
				s += (a[i]*e) - a[i];
				sum = min(sum, s);
			}
	}
	for(int i=1; i<n; i++) {
		for(auto e : fact[a[i]]) {
			long long s = sum;
			s -= a[i] - (a[i]/e);
			s += (a[0]*e) - a[0];
			sum = min(sum, s);
		}
	}
	cout << sum;
	return 0;
}


// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

vector<int> fact[105];
int a[5*(int)1e4+5];

int main() {
	IOS
	for(int i=1; i<=100; i++) {
		for(int j=2; j<=i; j++) {
			if(i%j==0) fact[i].push_back(j);
		}
	}
	long long sum = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) sum += a[i];
	for(int i=0; i<n; i++) {
		for(int j=i+1; j<n; j++) {
			for(auto e : fact[a[i]]) {
				long long s = sum;
				s += (a[j]*e)-a[j];
				s -= a[i] - (a[i]/e);
				sum = min(s, sum);
			}
			for(auto e : fact[a[j]]) {
				long long s = sum;
				s += (a[i]*e) - a[i];
				s -= a[j] - (a[j]/e);
				sum = min(s, sum);
			}
		}
	}
	cout << sum;
	return 0;
}


// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

vector<long long> fact[105];
long long a[5*(int)1e4+5];

int main() {
	IOS
	for(int i=1; i<=100; i++) {
		for(int j=1; j*j<=i; j++) {
			if(i%j==0) fact[i].push_back((long long)j);
			if(i%j==0 && j != i/j) fact[i].push_back((long long)i/j);
		}
	}
	long long sum = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	for(int i=0; i<n; i++) sum += a[i];
	long long tmpsum = sum;
	for(int i=1; i<n; i++) {
		for(auto e : fact[a[i]]) {
			long long s = tmpsum;
			s -= a[i] - (a[i]/e);
			s += (a[0]*e) - a[0];
			sum = min(sum, s);
		}
	}
	cout << sum;
	return 0;
}


// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

vector<int> fact[105];
int a[5*(int)1e4+5];

int main() {
	IOS
	for(int i=1; i<=100; i++) {
		for(int j=1; j*j<=i; j++) {
			if(i%j==0) fact[i].push_back(j);
			if(i%j==0 && j != i/j) fact[i].push_back(i/j);
		}
	}
	long long sum = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	for(int i=0; i<n; i++) sum += a[i];
	for(int i=1; i<n; i++) {
		for(auto e : fact[a[i]]) {
			long long s = sum;
			s -= a[i] - (a[i]/e);
			s += (a[0]*e) - a[0];
			sum = min(sum, s);
		}
	}
	cout << sum;
	return 0;
}


// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

vector<int> fact[105];
int a[5*(int)1e4+5];

int main() {
	IOS
	for(int i=1; i<=100; i++) {
		for(int j=2; j<=i; j++) {
			if(i%j==0) fact[i].push_back(j);
		}
	}
	long long sum = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	for(int i=0; i<n; i++) sum += a[i];
	for(int i=1; i<n; i++) {
		for(auto e : fact[a[i]]) {
			long long s = sum;
			s -= a[i] - (a[i]/e);
			s += (a[0]*e) - a[0];
			sum = min(sum, s);
		}
	}
	cout << sum;
	return 0;
}


// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

vector<int> fact[105];
int a[5*(int)1e4+5];

int main() {
	IOS
	for(int i=1; i<=100; i++) {
		for(int j=2; j<=i; j++) {
			if(i%j==0) fact[i].push_back(j);
		}
	}
	long long sum = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	for(int i=0; i<n; i++) sum += a[i];
	for(int i=1; i<n; i++) {
			for(auto e : fact[a[0]]) {
				long long s = sum;
				s -= a[0] - (a[0]/e);
				s += (a[i]*e) - a[i];
				sum = min(sum, s);
			}
	}
	for(int i=1; i<n; i++) {
		for(auto e : fact[a[i]]) {
			long long s = sum;
			s -= a[i] - (a[i]/e);
			s += (a[0]*e) - a[0];
			sum = min(sum, s);
		}
	}
	cout << sum;
	return 0;
}

	cout << sum;
	return 0;
}
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

vector<int> fact[105];
int a[5*(int)1e4+5];

int main() {
	IOS
	for(int i=1; i<=100; i++) {
		for(int j=2; j<=i; j++) {
			if(i%j==0) fact[i].push_back(j);
		}
	}
	long long sum = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	for(int i=0; i<n; i++) sum += a[i];
	for(int i=1; i<n; i++) {
			for(auto e : fact[a[0]]) {
				long long s = sum;
				s -= a[0] - (a[0]/e);
				s += (a[i]*e) - a[i];
				sum = min(sum, s);
			}
	}
	for(int i=1; i<n; i++) {
		for(auto e : fact[a[i]]) {
			long long s = sum;
			s -= a[i] - (a[i]/e);
			s += (a[0]*e) - a[0];
			sum = min(sum, s);
		}
	}
	cout << sum;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
//#define int long long
using namespace std;
typedef pair <int, int> pii;

void dout() {
    cerr << endl;
}

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e6 + 3, K = 21;
int n, a[N], cnt[N], ans;

void add(int x) {
    for (int s = x; s > 0; s = (s - 1) & x) {
        if (cnt[s] == 2) {
            break;
        }
        cnt[s]++;
    }
    if (cnt[0] < 2) {
        cnt[0]++;
    }
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i--) {
        int x = 0;
        for (int j = K - 1; j >= 0; j--) {
            if (!(i & (1 << j))) {
                int tmp = (x | (1 << j));
                if (cnt[tmp] == 2) {
                    x = tmp;
                }
            }
        }
        ans = max(ans, (a[i] | x));
        add(a[i]);
    }
    cout << ans;
}

signed main() {
//    freopen("input.txt", "r", stdin);
    int tc = 1;
//    cin >> tc;
    while (tc--) {
        solve();
//        cleanup();
    }
}


#include <iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e6+10;
int a[maxn];
int dp[1<<21][21];

void update(int num,int k)
{
    if(k > 20) return ;
    if(dp[num][k] > 1) return ;
    ++dp[num][k];
    update(num,k+1);
    if(num>>k&1)
        update(num^(1<<k),k);
}
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    for(int i = 1;i <= n; ++i)
        cin>>a[i];
    int ans = 0;
    for(int i = n;i >= 1; --i){
        int res = 0;
        int t = 0;
        for(int j = 20;j >= 0; --j)
        {
            if(a[i]>>j&1)
                res |= 1<<j;
            else if(dp[t|(1<<j)][20] > 1)
                res |= 1<<j,t |= 1<<j;
        }
        update(a[i],0);
        if(i <= n-2)
            ans = max(ans,res);
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
using  namespace std;
const int maxn=1e6+10;
int a[maxn];
int dp[1<<21][21];
void update(int num,int k)
{
    if(k>20)return;
    if(dp[num][k]>1)return;
    dp[num][k]++;
    update(num,k+1);
    if(num>>k&1)
        update(num^(1<<k),k);
}
int main(int argc, char const *argv[])
{
    int n;cin>>n;
    for (int i = 1; i <=n; ++i)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=n;i>=1;i--){
        int res=0;
        int t=0;
        for(int j=20;j>=0;j--)
        {
            if(a[i]>>j&1)res|=1<<j;
            else if(dp[t|(1<<j)][20]>1)
                res|=1<<j,t|=1<<j;
        }
        update(a[i],0);
        if(i<=n-2)ans=max(ans,res);
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
using  namespace std;
const int maxn=1e6+10;
int a[maxn];
int dp[1<<21][21];
void update(int num,int k)
{
    if(k>20)return;
    if(dp[num][k]>1)return;
    dp[num][k]++;
    update(num,k+1);
    if(num>>k&1)
        update(num^(1<<k),k);
}
int main(int argc, char const *argv[])
{
    int n;cin>>n;
    for (int i = 1; i <=n; ++i)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=n;i>=1;i--){
        int res=0;
        int t=0;
        for(int j=20;j>=0;j--)
        {
            if(a[i]>>j&1)res|=1<<j;
            else if(dp[t|(1<<j)][20]>1)
                res|=1<<j,t|=1<<j;
        }
        update(a[i],0);
        if(i<=n-2)ans=min(ans,res);
    }
    cout<<ans<<endl;

    return 0;
}


#include <iostream>
#include <algorithm>
using  namespace std;
const int maxn=1e6+10;
int a[maxn];
int dp[1<<21][21];
void update(int num,int k)
{
    if(k>20)return;
    if(dp[num][k]>1)return;
    dp[num][k]++;
    update(num,k+1);
    if(num>>k&1)
        update(num^(1<<k),k);
}
int main(int argc, char const *argv[])
{
    int n;cin>>n;
    for (int i = 1; i <=n; ++i)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=n;i>=1;i--)
    {
        int res=0;
        int t=0;
        for(int j=20;j>=0;j--)
        {
            if(a[i]>>j&1)res|=1<<j;
            else if(dp[t|(1<<j)][20]>1)
                res|=1<<j,t|=1<<j;
        }
        update(a[i],0);
        if(i<=n-2)ans=max(ans,res);
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
using  namespace std;
const int maxn=1e6+10;
int a[maxn];
int dp[1<<21][21];
void update(int num,int k)
{
    if(k>20)return;
    if(dp[num][k]>1)return;
    dp[num][k]++;
    update(num,k+1);
    if(num>>k&1)
        update(num^(1<<k),k);
}
int main(int argc, char const *argv[])
{
    int n;cin>>n;
    for (int i = 1; i <=n; ++i)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=n;i>=1;i--){
        int res=0;
        int t=0;
        for(int j=20;j>=0;j--)
        {
            if(a[i]>>j&1)res|=1<<j;
            else if(dp[t|(1<<j)][20]>1)
                res|=1<<j,t|=1<<j;
        }
        update(a[i],0);
        if(i<=n-2)ans=min(ans,res);
    }
    cout<<ans<<endl;
    return 0;
}