Fox Ciel is playing a game with numbers now. 

Ciel has *n* positive integers: *x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, ..., *x*<sub class="lower-index">*n*</sub>. She can do the following operation as many times as needed: select two different indexes *i* and *j* such that *x*<sub class="lower-index">*i*</sub> &gt; *x*<sub class="lower-index">*j*</sub> hold, and then apply assignment *x*<sub class="lower-index">*i*</sub> = *x*<sub class="lower-index">*i*</sub> - *x*<sub class="lower-index">*j*</sub>. The goal is to make the sum of all numbers as small as possible.

Please help Ciel to find this minimal sum.
The first line contains an integer *n* (2 ≤ *n* ≤ 100). Then the second line contains *n* integers: *x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, ..., *x*<sub class="lower-index">*n*</sub> (1 ≤ *x*<sub class="lower-index">*i*</sub> ≤ 100).
from collections import deque
class heap:
    def __init__(self):
        self.heap=deque()
        self.len=0
    def add(self,x):
        self.heap.appendleft(x)
        self.len+=1
        self.standize()
#        print(self.heap)
    def pop(self):
        a=self.heap.popleft()
        self.len-=1
        self.standize()
        return a
    def standize(self):        
        t=0
        k=len(self.heap)
        while 2*t+1<=k-1:
            if self.heap[t]<self.heap[2*t+1]:
                self.heap[2*t+1],self.heap[t]=self.heap[t],self.heap[2*t+1]
                t=2*t+1
            elif 2*t+2<=k-1 and self.heap[t]<self.heap[2*t+2]:
                self.heap[2*t+2],self.heap[t]=self.heap[t],self.heap[2*t+2]
                t=2*t+2
            else:
                break

n=int(input())
a=heap()
b=heap()
for i in map(int,input().split()):
    a.add(i)
    b.add(i)
b.pop()
#print(b.heap)
while a.heap[0]!=b.heap[0]:
    am=a.pop()
    bm=b.pop()
#    print(am,bm)
    a.add(am-bm)
    b.add(am-bm)
    if am-bm>b.heap[0]:
        break
print(a.heap[-1]*n)
