Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated.

There are n video cards in the shop, the power of the i-th video card is equal to integer value ai. As Vlad wants to be sure the new game will work he wants to buy not one, but several video cards and unite their powers using the cutting-edge technology. To use this technology one of the cards is chosen as the leading one and other video cards are attached to it as secondary. For this new technology to work it's required that the power of each of the secondary video cards is divisible by the power of the leading video card. In order to achieve that the power of any secondary video card can be reduced to any integer value less or equal than the current power. However, the power of the leading video card should remain unchanged, i.e. it can't be reduced.

Vlad has an infinite amount of money so he can buy any set of video cards. Help him determine which video cards he should buy such that after picking the leading video card and may be reducing some powers of others to make them work together he will get the maximum total value of video power.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of video cards in the shop.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 200 000) — powers of video cards.

Output

The only line of the output should contain one integer value — the maximum possible total power of video cards working together.

Examples

Input

4
3 2 15 9


Output

27


Input

4
8 2 2 7


Output

18

Note

In the first sample, it would be optimal to buy video cards with powers 3, 15 and 9. The video card with power 3 should be chosen as the leading one and all other video cards will be compatible with it. Thus, the total power would be 3 + 15 + 9 = 27. If he buys all the video cards and pick the one with the power 2 as the leading, the powers of all other video cards should be reduced by 1, thus the total power would be 2 + 2 + 14 + 8 = 26, that is less than 27. Please note, that it's not allowed to reduce the power of the leading video card, i.e. one can't get the total power 3 + 1 + 15 + 9 = 28.

In the second sample, the optimal answer is to buy all video cards and pick the one with the power 2 as the leading. The video card with the power 7 needs it power to be reduced down to 6. The total power would be 8 + 2 + 2 + 6 = 18.
import java.util.*;
import java.io.*;
public class helloworld {
 static long fact[];
 static long max;
 static int ans;
	static class Reader 
    { 
        final private int BUFFER_SIZE = 1 << 16; 
        private DataInputStream din; 
        private byte[] buffer; 
        private int bufferPointer, bytesRead; 
  
        public Reader() 
        { 
            din = new DataInputStream(System.in); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public Reader(String file_name) throws IOException 
        { 
            din = new DataInputStream(new FileInputStream(file_name)); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public String readLine() throws IOException 
        { 
            byte[] buf = new byte[64]; // line length 
            int cnt = 0, c; 
            while ((c = read()) != -1) 
            { 
                if (c == '\n') 
                    break; 
                buf[cnt++] = (byte) c; 
            } 
            return new String(buf, 0, cnt); 
        } 
  
        public int nextInt() throws IOException 
        { 
            int ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do
            { 
                ret = ret * 10 + c - '0'; 
            }  while ((c = read()) >= '0' && c <= '9'); 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public long nextLong() throws IOException 
        { 
            long ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public double nextDouble() throws IOException 
        { 
            double ret = 0, div = 1; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
  
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
  
            if (c == '.') 
            { 
                while ((c = read()) >= '0' && c <= '9') 
                { 
                    ret += (c - '0') / (div *= 10); 
                } 
            } 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        private void fillBuffer() throws IOException 
        { 
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
            if (bytesRead == -1) 
                buffer[0] = -1; 
        } 
  
        private byte read() throws IOException 
        { 
            if (bufferPointer == bytesRead) 
                fillBuffer(); 
            return buffer[bufferPointer++]; 
        } 
  
        public void close() throws IOException 
        { 
            if (din == null) 
                return; 
            din.close(); 
        } 
    } 
	
	static long getSum(int index , long BITree[]) 
    { 
		
        long  sum = 0; // Iniialize result 
      
        // index in BITree[] is 1 more than 
        // the index in arr[] 
    
      
        // Traverse ancestors of BITree[index] 
        while(index>0) 
        { 
            // Add current element of BITree  
            // to sum 
            sum += BITree[index]; 
      
            // Move index to parent node in  
            // getSum View 
            index -= index & (-index); 
        } 
        return sum; 
    } 
  
	static int getMid(int s, int e) 
    { 
        return s + (e - s) / 2; 
    } 
  
    /* 
    * A recursive function to get the sum  
    of values in given range of the array. 
    * The following are parameters for this function. 
    *  
    * st -> Pointer to segment tree 
    * node -> Index of current node in 
    *         the segment tree. 
    * ss & se -> Starting and ending indexes 
    *         of the segment represented 
    *         by current node, i.e., st[node] 
    * l & r -> Starting and ending indexes 
    *         of range query 
    */
    static int MaxUtil(int[] st, int ss, int se,  
                        int l, int r, int node)  
    { 
          
        // If segment of this node is completely 
        // part of given range, then return 
        // the max of segment 
        if (l <= ss && r >= se) 
            return st[node]; 
  
        // If segment of this node does not 
        // belong to given range 
        if (se < l || ss > r) 
            return -1; 
  
        // If segment of this node is partially 
        // the part of given range 
        int mid = getMid(ss, se); 
  
        return Math.max(MaxUtil(st, ss, mid, l, r, 2 * node + 1), 
                    MaxUtil(st, mid + 1, se, l, r, 2 * node + 2)); 
    } 
  
    /* 
    * A recursive function to update the  
    nodes which have the given index in their 
    * range. The following are parameters  
    st, ss and se are same as defined above 
    * index -> index of the element to be updated. 
    */
    static void updateValue(int arr[], int[] st, int ss, 
                    int se, int index, int value, int node) 
    { 
        if (index < ss || index > se) 
        { 
            System.out.println("Invalid Input"); 
            return; 
        } 
  
        if (ss == se) 
        { 
  
            // update value in array and in segment tree 
            arr[index] = value; 
            st[node] = value; 
        }  
        else
        { 
            int mid = getMid(ss, se); 
  
            if (index >= ss && index <= mid) 
                updateValue(arr, st, ss, mid, index, value, 2 * node + 1); 
            else
                updateValue(arr, st, mid + 1, se, index, value, 2 * node + 2); 
  
            st[node] = Math.max(st[2 * node + 1], st[2 * node + 2]); 
        } 
        return; 
    } 
  
    // Return max of elements in range from 
    // index l (query start) to r (query end). 
    static int getMax(int[] st, int n, int l, int r) 
    { 
  
        // Check for erroneous input values 
        if (l < 0 || r > n - 1 || l > r)  
        { 
            System.out.printf("Invalid Input\n"); 
            return -1; 
        } 
  
        return MaxUtil(st, 0, n - 1, l, r, 0); 
    } 
  
    // A recursive function that constructs Segment 
    // Tree for array[ss..se]. si is index of 
    // current node in segment tree st 
    static int constructSTUtil(int arr[], int ss, 
                        int se, int[] st, int si)  
    { 
          
        // If there is one element in array, store 
        // it in current node of segment tree and return 
        if (ss == se)  
        { 
            st[si] = arr[ss]; 
            return arr[ss]; 
        } 
  
        // If there are more than one elements, then 
        // recur for left and right subtrees and 
        // store the max of values in this node 
        int mid = getMid(ss, se); 
  
        st[si] = Math.max(constructSTUtil(arr, ss, mid, st, si * 2 + 1), 
                constructSTUtil(arr, mid + 1, se, st, si * 2 + 2)); 
  
        return st[si]; 
    } 
  
    /* 
    * Function to construct segment tree from 
    given array. This function allocates 
    * memory for segment tree. 
    */
    static int[] constructST(int arr[], int n) 
    { 
  
        // Height of segment tree 
        int x = (int) Math.ceil(Math.log(n) / Math.log(2)); 
  
        // Maximum size of segment tree 
        int max_size = 2 * (int) Math.pow(2, x) - 1; 
  
        // Allocate memory 
        int[] st = new int[max_size]; 
  
        // Fill the allocated memory st 
        constructSTUtil(arr, 0, n - 1, st, 0); 
  
        // Return the constructed segment tree 
        return st; 
    } 
    public static void updateBIT(int n, int index,  
                                        long val , long BITree[] ) 
    { 
        // index in BITree[] is 1 more than  
        // the index in arr[] 
       
        // Traverse all ancestors and add 'val' 
        while(index <= n) 
        { 
        // Add 'val' to current node of BIT Tree 
        BITree[index] += val; 
      
        // Update index to that of parent  
        // in update View 
        index += index & (-index); 
        } 
    } 
    static long mod = 1000000007;
   static long pow(long a , long b , long c)
   {
	   
	   if(b==0)
		   return 1;
	   
	   long ans = pow(a,b/2,c);
	   if(b%2 == 0)
		   return ans*ans%c;
	   
	   return ans*ans%c*a%c;
   }
   
   static long modInverse(long a , long b)
   {
	   return pow(a,b-2,mod);
   }
   
   
   static double d(int x1 , int y1 , int x2 , int y2)
   {
	   double d1 = x1-x2;
	   double d2 = y1-y2;
	   
	   return Math.sqrt(d1*d1-d2*d2);
   }
  

static int low[];
static int p[];
static int parent(int x , int k , int dp[][])
{
	if(k==0)
		return x;
while(k > 0)
{
	if(x == -1)
		break;
	
	int up = low[k];
	k -= p[up];
	x = dp[x][up];
}
return x;
}


static void d(int n , LinkedList<Integer> arr[] , boolean visited[] , int dp[][] , int h[] , int p,int lev)
{
	visited[n] = true;
	int lim = low[visited.length];
	
	dp[n][0] = p;
	int temp = n;
	for(int j = 1 ; j <= lim ; j++)
	{
		if(dp[n][j-1] == -1)
			break;
		
		dp[n][j] = dp[dp[n][j-1]][j-1];
	}
	
	h[n] = lev;
	
	for(Integer i : arr[n])
	{
		if(!visited[i])
		{
			d(i,arr,visited,dp,h,n,lev+1);
		}
	}
}

static int lca(int a , int b , int dp[][] , int h[])
{
	if(h[a] > h[b])
	{
		a = parent(a,h[a]-h[b],dp);
		
	}
	
	else if(h[b] > h[a])
	{
		b = parent(b,h[b]-h[a],dp);
	}
	
	if(a==b)
		return a;
	
	
	int l = 1 , r = h.length;
	
	while(l < r)
	{
		int mid = (l+r)/2;
		if(parent(a,mid,dp) == parent(b,mid,dp))
			r = mid;
		
		else
			l = mid+1;
	}
	
	return parent(a,l,dp);
}


static void dfs(int n , LinkedList<Integer> arr[] , boolean visited[] , int dp[] , int idx[] , int ans[])
{
	visited[n] = true;
	for(Integer i : arr[n])
	{
		if(!visited[i])
		{
			dfs(i,arr,visited,dp,idx,ans);
			dp[n] += dp[i];
		}
	}
	if(n != 1)
	ans[idx[n]] = dp[n];
	//System.out.println(dp[n] + " " + idx[n]);
}

public static void main(String []args) throws IOException
{
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int arr[] = new int[200001];
	for(int i = 0 ; i < n ; i++)
	{
		arr[sc.nextInt()]++;
	}
	for(int i = 1 ; i <= 200000 ; i++)
	{
		arr[i] += arr[i-1];
	}
	
	long ans = 0;
	for(int i = 1 ; i <= 200000 ; i++)
	{
		if(arr[i]-arr[i-1] > 0)
		{
			long temp = 0;
			for(int j = i ; j <= 200000 ; j += i)
			{
				temp += (long)j * (long)(arr[Math.min(200000, j+i-1)] - arr[(j-1)]);
			}
			ans = Math.max(ans,temp);
		}
	}
	System.out.println(ans);
}
}