Fox Ciel is playing a game with numbers now. 

Ciel has n positive integers: x_1, x_2, ..., x_{n}. She can do the following operation as many times as needed: select two different indexes i and j such that x_{i} > x_{j} hold, and then apply assignment x_{i} = x_{i} - x_{j}. The goal is to make the sum of all numbers as small as possible.

Please help Ciel to find this minimal sum.


-----Input-----

The first line contains an integer n (2 ≤ n ≤ 100). Then the second line contains n integers: x_1, x_2, ..., x_{n} (1 ≤ x_{i} ≤ 100).


-----Output-----

Output a single integer — the required minimal sum.


-----Examples-----
Input
2
1 2

Output
2

Input
3
2 4 6

Output
6

Input
2
12 18

Output
12

Input
5
45 12 27 30 18

Output
15



-----Note-----

In the first example the optimal way is to do the assignment: x_2 = x_2 - x_1.

In the second example the optimal sequence of operations is: x_3 = x_3 - x_2, x_2 = x_2 - x_1.

Difficulty: EASY
Tags: Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
def findMaxSubarraySum(arr, n, sum):
	curr_sum = arr[0]
	max_sum = 0
	start = 0
	for i in range(1, n):
		if curr_sum <= sum:
			max_sum = max(max_sum, curr_sum)
		while curr_sum + arr[i] > sum and start < i:
			curr_sum -= arr[start]
			start += 1
		curr_sum += arr[i]
	if curr_sum <= sum:
		max_sum = max(max_sum, curr_sum)
	return max_sum
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
l = l[::-1]
while l.count(l[0]) != n:
	for i in range(n):
		l[i] -= findMaxSubarraySum(l, n, l[i] - 1)
print(sum(l))


a = int(input())
b = input().split()
factors = []
for x in range(1, int(b[0]) + 1):
	if int(b[0]) % x == 0:
		factors.append(str(x))
hc = 1
for y in range(0, len(factors)):
	c = 0
	for z in range(0, a):
		if int(b[z]) % int(factors[y]) == 0:
			c = c + 1
		if c == a:
			hc = int(factors[y])
d = 0
for p in range(0, a):
	if int(b[p]) == int(b[0]):
		d = d + 1
if d == a:
	print(str(int(b[0]) * a))
else:
	print(str(hc * a))


n = int(input())
d = 1000000000.0
x = list(map(int, input().split()))
x1 = x[:]
for i in range(n + 1):
	for j in range(len(x) - 1):
		try:
			if x[j + 1] - x[j] > 0:
				d = min(d, x[j + 1] - x[j])
				x.append(x[j + 1] - x[j])
			elif x[j] - x[j + 1] > 0:
				d = min(d, x[j] - x[j + 1])
				x.append(x[j] - x[j + 1])
			x = sorted(set(x))
		except IndexError:
			break
if d == 1000000000.0:
	print(sum(x1))
else:
	d = min(d, min(x))
	print(n * d)


from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = 0
for i in range(n):
	g = gcd(a[i], g)
print(g * n)


n = int(input())
ele = input().split()
ele = list(map(int, ele))
ele.sort()
while ele[0] != ele[-1]:
	for i in range(len(ele) - 1, 0, -1):
		if ele[i] % ele[0] == 0:
			ele[i] = ele[0]
		else:
			ele[i] = ele[i] % ele[0]
		ele.sort()
print(len(ele) * ele[0])


from functools import *
from fractions import *
print(int(input()) * reduce(gcd, map(int, input().split())))


def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
n = int(input())
nS = [int(x) for x in input().split()]
answer = nS[0]
for i in nS[1:]:
	answer = gcd(answer, i)
print(answer * n)


import math
n = int(input())
noList = list(map(int, input().split()))
result = math.gcd(noList[0], noList[1])
for i in range(2, n):
	result = math.gcd(result, noList[i])
print(result * n)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
x = list(invr())
temp = 0
while temp != n - 1:
	temp = 0
	x.sort(reverse=True)
	for i in range(1, n):
		diff = x[i - 1] - x[i]
		if diff != 0:
			x[i - 1] = diff
		else:
			temp += 1
print(sum(x))


num = int(input())
arr = list(map(int, input().split()))
mn = min(arr)
mx = max(arr)
while mn != mx:
	arr = [i - mn if i != mn else mn for i in arr]
	mn = min(arr)
	mx = max(arr)
print(sum(arr))


import sys
import math
from sys import stdin, stdout

def sieve(N):
	primeNumbers = [True] * (N + 1)
	primeNumbers[0] = False
	primeNumbers[1] = False
	i = 2
	while i * i <= N:
		j = i
		if primeNumbers[j]:
			while j * i <= N:
				primeNumbers[j * i] = False
				j += 1
		i += 1
	return primeNumbers

def getPrime(N):
	primes = sieve(N)
	result = []
	for i in range(len(primes)):
		if primes[i]:
			result.append(i)
	return result

def factor(N):
	factors = []
	i = 1
	while i * i <= N:
		if N % i == 0:
			factors.append(i)
			if i != N // i:
				factors.append(N // i)
		i += 1
	return sorted(factors)

def reduceB(b):
	mod = 0
	for i in range(0, len(b)):
		mod = (mod * 10 + ord(b[i])) % 1000000007
	return mod

def gcd(a, b):
	if a < b:
		return gcd(b, a)
	if b == 0:
		return a
	return gcd(b, a % b)

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(input())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def checkEqual(arr):
	for i in range(0, len(arr) - 1):
		if arr[i] != arr[i + 1]:
			return True
	return False

def main():
	n = int(input())
	arr = get_ints_in_list()
	while checkEqual(arr):
		arr.sort()
		start = n - 1
		while start >= 0:
			i = 0
			tmp = sys.maxsize
			while i < n:
				if start == i:
					i += 1
					continue
				if arr[start] > arr[i]:
					tmp = min(arr[start] - arr[i], tmp)
				i += 1
			if tmp != sys.maxsize:
				arr[start] = tmp
			start -= 1
	print(sum(arr))
main()


n = int(input())
l = sorted(map(int, input().split()))
while len(set(l)) != 1:
	l[-1] -= l[0]
	l.sort()
print(sum(l))


def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
n = int(input())
a = list(map(int, input().split()))
g = 0
for i in range(n):
	g = gcd(g, a[i])
print(n * g)


n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
K = 100
while K:
	K -= 1
	for i in range(n):
		for j in range(n):
			if i != j and a[j] and (a[i] > a[j]):
				if a[i] % a[j] == 0:
					a[i] = a[i] % a[j] + a[j]
				else:
					a[i] = a[i] % a[j]
print(sum(a))


n = int(input())
x = list(map(int, input().split()))
for i in x[1:]:
	s = abs(i - x[0])
	if s:
		break
if s > 0:
	while s != 1:
		t = s
		for i in x:
			t = t if abs(i - t) == 0 or abs(i - t) % t == 0 else abs(i - t) % t
		if t == s:
			break
		s = t
	print(s * n)
else:
	print(x[0] * n)


n = int(input())
number = [int(i) for i in input().split()]
while True:
	tem_min = number[0]
	for i in range(n):
		if number[i] < tem_min:
			tem_min = number[i]
	for i in range(n):
		if number[i] % tem_min == 0:
			number[i] = tem_min
		else:
			number[i] = number[i] % tem_min
	if sum(number) == n * tem_min:
		break
print(sum(number))


from math import gcd
n = int(input())
x = list(map(int, input().split(' ')))
gcdt = gcd(x[0], x[1])
for i in range(n):
	gcdt = gcd(gcdt, x[i])
print(gcdt * n)


n = int(input())
s = [int(i) for i in input().split()]
while s.count(s[0]) != n:
	a = min(s)
	for i in range(n):
		if s[i] > a:
			s[i] -= a
print(sum(s))


import fractions
n = int(input())
a = 0
for x in input().split():
	a = fractions.gcd(a, int(x))
print(a * n)


n = int(input())
a = [int(x) for x in input().split()]
while any((x != a[0] for x in a)):
	a.sort()
	a = [a[i] - a[0] if a[i] > a[0] else a[i] for i in range(0, n)]
print(sum(a))


from math import gcd
n = int(input())
A = input().split()
hcf = int(A[0])
for i in A:
	hcf = gcd(int(i), hcf)
print(n * hcf)


from fractions import gcd
from functools import reduce

def main():
	n = int(input())
	a = sorted(list(map(int, input().split(' '))), key=lambda x: -x)
	return reduce(gcd, a) * n
print(main())


n = int(input())
a = [int(i) for i in input().split()]
b = min(a)
while max(a) != b:
	for i in range(n):
		if a[i] != b:
			if a[i] % b == 0:
				a[i] = b
			else:
				a[i] = a[i] % b
	b = min(a)
print(b * n)


n = int(input())
number = [int(i) for i in input().split()]
odd = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
lenth = len(odd)
result = [100] * lenth
for i in range(n):
	cur = number[i]
	tem = [0] * lenth
	for j in range(lenth):
		while cur % odd[j] == 0:
			cur = cur / odd[j]
			tem[j] += 1
		if cur % odd[j] != 0:
			if tem[j] < result[j]:
				result[j] = tem[j]
sumpre = 1
for i in range(lenth):
	if result[i] != 0 and result[i] != 100:
		temp = result[i]
		while temp > 0:
			sumpre *= odd[i]
			temp -= 1
sumnum = n * sumpre
print(sumnum)


n = int(input())
l = list(map(int, input().split()))
m = 100000
t = 0
s = []
l.sort()
while t < 100:
	l.sort()
	for i in range(n):
		for j in range(i + 1, n):
			if l[j] > l[i]:
				l[j] = l[j] - l[i]
	s.append(sum(l))
	t += 1
print(min(s))


n = int(input())
l = list(map(int, input().strip().split(' ')))
result = []
o = len(l)
l = set(l)
l = sorted(l)
i = len(l) - 1
length = len(l) - 1
while l[i] > l[i - 1] and i != 0:
	if l[i] > l[i - 1]:
		l[i] -= l[i - 1]
	i -= 1
	if i == 0:
		l = set(l)
		l = sorted(l)
		i = len(l) - 1
print(l[0] * o)


import sys
inp = sys.stdin.readlines()
n = int(inp[0])
data = list(map(int, inp[1].split()))

def secondLargest(x):
	list.sort(x)
	i = -2
	while x[-1] == x[i]:
		i -= 1
	return x[i]
while True:
	if max(data) - min(data) == 0:
		print(data[0] * n)
		break
	else:
		data[data.index(max(data))] = max(data) - secondLargest(data)


n = int(input())
x = [int(q) for q in input().split()]

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
g = x[0]
for i in range(1, len(x)):
	g = gcd(g, x[i])
print(len(x) * g)


n = int(input())
l = list(map(int, input().split()))
flag = 0
while 1:
	for i in range(n):
		for j in range(n):
			if i == j:
				continue
			if len(set(l)) == 1:
				flag = 1
				print(l[0] * len(l))
				break
			if l[i] > l[j]:
				l[i] -= l[j]
			if l[i] < l[j]:
				l[j] -= l[i]
		if flag == 1:
			break
	if flag == 1:
		break
if flag == 0:
	print(l[0] * len(l))


def f(x, y):
	while True:
		t = x % y
		x = y
		y = t
		if t == 0:
			return x
n = int(input())
x = list(map(int, input().split()))
j = x[0]
for i in x:
	j = f(j, i)
print(j * n)


def line():
	return [int(c) for c in input().split()]
n = int(input())
x = line()

def gcd(a, b):
	if b > a:
		(a, b) = (b, a)
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)
from functools import reduce
print(reduce(gcd, x) * n)


n = int(input())
x = list(map(int, input().split()))
x.sort()
while x[-1] != x[0]:
	x[-1] = x[-1] - x[0]
	x.sort()
print(sum(x))


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
n = int(input())
l = list(map(int, input().split()))
num1 = l[0]
num2 = l[1]
gcd = find_gcd(num1, num2)
for i in range(2, len(l)):
	gcd = find_gcd(gcd, l[i])
print(gcd * len(l))


n = int(input())
a = list(map(int, input().split()))

def fn(a, b):
	(a, b) = (max(a, b), min(a, b))
	if a % b == 0:
		return b
	else:
		return fn(a % b, b)
while min(a) != max(a):
	(t1, t2) = (max(a), min(a))
	i1 = a.index(t1)
	i2 = a.index(t2)
	t1 = t2 = fn(t1, t2)
	a[i1] = a[i2] = t1
print(sum(a))


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
i = arr[0]

def gcd(arr, n):
	i = arr[0]
	while i > 1:
		c = 0
		for z in arr:
			if z % i == 0:
				c = c + 1
		if c == n:
			return i
		i = i - 1
	return 1
print(n * gcd(arr, n))


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
n = int(input())
arr = list(map(int, input().split()))
g = arr[0]
for c in arr:
	g = math.gcd(g, c)
print(g * n)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
n = int(input())
x = list(map(int, input().split()))
d = max(x)
i = 0
while i < n:
	d = gcd(d, x[i])
	i = i + 1
print(d * n)


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from sys import *
(n, a) = (int(input()), arr_inp())
for i in range(min(a), 0, -1):
	c = 0
	for j in a:
		if j % i:
			break
		else:
			c += 1
	if c == n:
		exit(print(i * n))


def gdb(a, b):
	while b != 0:
		tem = a % b
		a = b
		b = tem
	return a
t = int(input())
line = input()
ar = line.split()
x = int(ar[0])
y = int(ar[1])
ans = gdb(max(x, y), min(x, y))
for i in range(2, t):
	n = int(ar[i])
	ans = gdb(max(ans, n), min(ans, n))
print(ans * t)


from math import gcd
n = int(input())
res = 0
for i in input().split():
	res = gcd(res, int(i))
print(res * n)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
n = int(input())
x = list(map(int, input().split()))
t = int(x[0])
i = 0
for i in range(n):
	t = gcd(t, int(x[i]))
print(n * t)


n = int(input())
l = list(map(int, input().split()))
global minE
minE = min(l)

def minimize(minE):
	o = False
	currMin = minE
	for i in range(n):
		if l[i] > minE:
			if l[i] % minE == 0:
				k = l[i] - (l[i] / minE - 1) * minE
				l[i] = k
				if currMin > k:
					currMin = k
			else:
				k = l[i] - l[i] // minE * minE
				l[i] = k
				if currMin > k:
					currMin = k
			o = True
	if o:
		minimize(currMin)
	else:
		return
x = minimize(minE)
print(int(sum(l)))


n = int(input())
s = [int(i) for i in input().split()]
s.sort()

def operate(x, lista):
	for i in range(x):
		for j in range(x):
			if lista[j] > lista[i]:
				lista[j] = lista[j] - lista[i]
				lista.sort()
	return (x, lista)

def test(x, lista):
	t = 0
	for i in range(x):
		if lista[i] != lista[0]:
			t += 1
	if t != 0:
		return True
	else:
		return False
while test(n, s):
	operate(n, s)
else:
	print(sum(s))


import math
n = int(input())
l = list(map(int, input().split()))
ans = l[0]
for i in range(1, n):
	ans = math.gcd(ans, l[i])
print(ans * n)


from sys import stdin, stdout
from math import gcd
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	n = nmbr()
	a = lst()
	g = a[0]
	for v in a[1:]:
		g = gcd(g, v)
	print(g * n)


from collections import deque
n = int(input())
li = deque(sorted(list(map(int, input().split()))))
g = li.popleft()

def gcd(a, b):
	if a == b or a * b == 0:
		return min(abs(a), abs(b))
	else:
		smaller = min(abs(a), abs(b))
		larger = max(abs(a), abs(b))
		return gcd(larger - smaller, smaller)
while li and g != 1:
	g = gcd(g, li.popleft())
print(g * n)


from functools import reduce
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
s = reduce(gcd, a)
print(s * n)


def __gcd(a, b):
	if b == 0:
		return a
	return __gcd(b, a % b)
n = int(input())
a = list(map(int, input().split()))
gcd = a[0]
for i in range(1, len(a)):
	gcd = __gcd(a[i], gcd)
print(n * gcd)


n = int(input())
a = list(map(int, input().split()))

def euclid(x, y):
	p = max(x, y)
	q = min(x, y)
	r = p % q
	while r > 0:
		p = q
		q = r
		r = p % q
	return q
r = a[0]
for i in range(1, n):
	r = euclid(r, a[i])
print(r * n)


n = int(input())
l = list(map(int, input().split()))
while len(set(l)) != 1:
	l.sort()
	for i in range(1, len(l) + 1):
		for j in range(1, len(l) + 1):
			if l[-i] > l[-j]:
				l[-i] = l[-i] - l[-j]
				continue
print(sum(l))


from math import gcd
n = int(input())
arr = list(map(int, input().split()))
al = arr[0]
for m in arr[1:]:
	al = gcd(m, al)
print(al * n)


from fractions import gcd
n = int(input())
l = list(map(int, input().split()))
res = l[0]
for i in range(1, n):
	res = gcd(res, l[i])
print(res * n)


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')

def gcd(a, b):
	if a < b:
		t = b
		b = a
		a = t
	while b != 0:
		t = b
		b = a % b
		a = t
	return a
n = int(input())
l = RI()
temp = l[0]
for i in range(1, n):
	temp = gcd(temp, l[i])
print(temp * n)


def op(lst):
	return len(set(lst)) == 1
x = int(input())
a = list(map(int, input().split()))
while op(a) == False:
	for i in range(len(a) - 1):
		if a[i] != a[i + 1]:
			a[i] = min(a[i], abs(a[i] - a[i + 1]))
	if a[len(a) - 1] != a[0]:
		a[len(a) - 1] = min(a[len(a) - 1], abs(a[len(a) - 1] - a[0]))
print(a[0] * len(a))


n = int(input())
b = list(map(int, input().split()))
c = 0
while c < n:
	m = min(b)
	c = 0
	for i in range(n):
		if m == b[i]:
			c += 1
		else:
			b[i] = b[i] % m
			if b[i] == 0:
				b[i] = m
print(sum(b))


n = int(input())
ar = list(map(int, input().split()))
mod = lambda a, b: a % b if a % b != 0 else b
while 1:
	changed = False
	m = min(ar)
	for i in range(len(ar)):
		t = mod(ar[i], m)
		if t != ar[i]:
			changed = True
			ar[i] = t
	if not changed:
		break
print(sum(ar))


n = int(input())
l = list(map(int, input().split()))
while 1:
	t = 0
	l.sort()
	for i in range(n - 1, 0, -1):
		if l[i] > l[i - 1]:
			l[i] -= l[i - 1]
			t = 1
			break
	if t == 0:
		break
print(sum(l))


n = int(input())
x = list(map(int, input().split()))

def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
res = x[0]
for i in x[1:]:
	res = gcd(res, i)
print(res * len(x))


n = int(input())
a = list(map(int, input().split()))
while len(set(a)) != 1:
	w = min(a)
	for j in range(n):
		if a[j] != w and w != 0:
			if a[j] % w == 0:
				a[j] = w
			else:
				a[j] = a[j] % w
print(n * a[0])


n = int(input())
arr = [int(i) for i in input().split(' ')]
count = 0
while count < n - 1:
	count = 0
	arr.sort()
	for i in range(1, n):
		if arr[i] > arr[i - 1] and arr[i - 1] != 0:
			arr[i] -= arr[i - 1]
		else:
			count += 1
print(sum(arr))


cnt = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
while True:
	for i in range(1, cnt):
		if arr[i] > arr[0]:
			arr[i] = arr[i] % arr[0]
			if arr[i] == 0:
				arr[i] = arr[0]
		arr.sort()
	if arr[0] == arr[cnt - 1]:
		break
sum = 0
for i in arr:
	sum += i
print(sum)


from collections import deque
import bisect
n = int(input())
list1 = list(map(int, input().split()))
list1.sort()
list1 = deque(list1)
while True:
	x = list1.pop()
	y = list1.popleft()
	if x > y:
		x -= y
		bisect.insort(list1, x)
		bisect.insort(list1, y)
	else:
		bisect.insort(list1, x)
		bisect.insort(list1, y)
		break
print(sum(list1))


n = int(input())
x = [int(i) for i in input().split()]
x.sort()

def f(x, y):
	for i in range(1, x + 1):
		if x % i == 0 and y % i == 0:
			m = i
	return m
a = f(x[0], x[1])
for i in range(2, len(x)):
	a = f(a, x[i])
print(n * a)


n = int(input())
s = input().split()
for i in range(n):
	s[i] = int(s[i])
s = sorted(s)
m = s[0]
while m > 1:
	jud = 0
	for i in s:
		if i % m != 0:
			jud = 1
	if jud == 0:
		break
	m -= 1
print(m * n)


n = int(input())
a = n * [0]
s = input()
a = s.split()
for i in range(n):
	a[i] = int(a[i])
for i in range(1, 101):
	div = 101 - i
	boolean = 1
	for i in range(n):
		if a[i] % div != 0:
			boolean = 0
	if boolean == 1:
		print(n * div)
		break


from fractions import gcd
n = int(input())
arr = list(map(int, input().split()))
ans = arr[0]
for i in range(1, len(arr)):
	ans = gcd(ans, arr[i])
print(ans * len(arr))


def gcd(a, b):
	c = a % b
	return gcd(b, c) if c else b
(n, t) = (int(input()), list(map(int, input().split())))
j = t[0]
for i in t[1:]:
	j = gcd(i, j)
print(n * j)


def nod(x, y):
	while x > 0 and y > 0:
		if x > y:
			x %= y
		else:
			y %= x
	return x + y
s = int(input())
a = [int(x) for x in input().split()]
c = a[0]
for i in range(1, s):
	c = nod(c, a[i])
print(c * s)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def gcd(a, b):
	while b > 0:
		c = a % b
		a = b
		b = c
	return a
n = mint()
z = None
for i in mints():
	if z == None:
		z = i
	else:
		z = gcd(z, i)
print(n * z)


n = int(input())
numbers = sorted((int(x) for x in input().split()))
while True:
	element = next((first for (first, second) in zip(numbers, numbers[1:]) if second > first), None)
	if element is None:
		break
	numbers = sorted((number - element if number > element else number for number in numbers))
print(sum(numbers))


import sys
from collections import defaultdict
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	d = inp()
	v = inlt()
	v.sort()
	while True:
		f = False
		for i in range(1, d):
			if v[i] > v[i - 1]:
				r = v[i] - v[i - 1]
				v[i] = r
				f = True
				break
		if not f:
			break
		v.sort()
	print(sum(v))
main()


def gcd(x, y):
	if y == 0 or x == 0:
		return max(x, y)
	t = x % y
	while t != 0:
		x = y
		y = t
		t = x % y
	return y

def main():
	readData = lambda : list(map(int, input().split()))
	n = int(input())
	X = list(readData())
	d = 0
	for x in X:
		d = gcd(d, x)
	print(d * len(X))

def __starting_point():
	main()
__starting_point()


import sys
n = int(input())
x = list(map(int, sys.stdin.readline().split()))

def pgcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
ans = x[0]
for i in range(1, n):
	ans = pgcd(ans, x[i])
print(n * ans)


def gcd(a, b):
	c = max(a, b)
	b = min(a, b)
	a = c
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)
n = int(input())
l = list(map(int, input().split()))
g = l[0]
for i in range(1, n):
	g = gcd(g, l[i])
print(n * g)


from functools import reduce
gcd = lambda a, b: gcd(b, a % b) if b else a
print(int(input()) * reduce(gcd, map(int, input().split())))


n = int(input())
stro = list(map(int, input().split()))
while min(stro) != max(stro):
	for i in range(n):
		for j in range(n):
			if stro[i] > stro[j]:
				stro[i] = stro[i] - stro[j]
print(sum(stro))


n = int(input())
a = list(map(int, input().split()))
for i in range(1000):
	a = sorted(a)
	a.reverse()
	for j in range(n - 1):
		if a[j] > a[j + 1]:
			a[j] -= a[j + 1]
print(sum(a))


n = int(input())
lst = list(map(int, input().split()))
while min(lst) != max(lst):
	a = lst.index(max(lst))
	b = lst.index(min(lst))
	lst[a] = lst[a] - lst[b]
print(sum(lst))


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
while len(set(l)) > 1:
	ma = max(l)
	for i in range(n - 2, -1, -1):
		if l[i] != ma:
			mi = l[i]
	l[n - 1] = ma - mi
	l = sorted(l)
print(sum(l))


import math
n = int(input())
mylist = list(map(int, input().split(None, n)[:n]))
for i in range(n):
	if i == 0:
		min_sum = mylist[i]
	else:
		min_sum = math.gcd(min_sum, mylist[i])
print(n * min_sum)


import math
a = int(input())
z = list(map(int, input().split()))
z.sort()
flag = 0
for i in range(1, len(z)):
	if math.gcd(z[i], z[0]) == 1:
		flag = 1
		break
	else:
		z[0] = math.gcd(z[i], z[0])
if flag == 0:
	print(z[0] * len(z))
else:
	print(len(z))


from functools import reduce
n = int(input())
m = [int(x) for x in input().split()]
m = sorted(m, reverse=True)

def GCD(a, b):
	if b == 0:
		return a
	else:
		return GCD(b, a % b)
gcd = reduce(lambda x, y: GCD(x, y), m)
print(gcd * n)


n = int(input())
a = list(map(int, input().split()))
flag = 0
for i in range(100):
	a.sort()
	for i in range(len(a) - 1, 0, -1):
		if a[i] - a[i - 1] > 0:
			a[i] = a[i] - a[i - 1]
print(sum(a))


from sys import stdin

def main():
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split()))
	while True:
		l.sort()
		i = max(range(1, n), key=lambda _: l[_] - l[_ - 1])
		if l[i] == l[i - 1]:
			return sum(l)
		l[i] -= l[i - 1]
print(main())


n = int(input())
A = list(map(int, input().split()))
from math import gcd
g = 0
for a in A:
	g = gcd(g, a)
print(n * g)


n = int(input())
a = list(map(int, input().split()))
for i in range(n * 2):
	a = sorted(a, reverse=True)
	for j in range(1, n):
		while a[j] and a[0] > a[j]:
			a[0] -= a[j]
print(sum(a))


n = int(input())
l = sorted(list(map(int, input().split())))
changed = True
while changed:
	changed = False
	m = l[0]
	for i in range(1, n):
		if l[i] > m:
			mod = l[i] % m
			l[i] = mod if mod else m
			changed = True
	l = sorted(l)
print(sum(l))


n = int(input())
x = [int(a) for a in input().split()]
x.sort()
while x[0] != x[-1]:
	i = -2
	while x[-1] == x[i]:
		i -= 1
	x[-1] -= x[i]
	x.sort()
print(sum(x))


n = int(input())
x = [int(i) for i in input().split()]
m = min(x)
for i in range(m, 0, -1):
	isok = True
	for j in x:
		if j % i:
			isok = False
			break
	if isok:
		print(i * n)
		exit(0)


n = int(input())
l = [int(i) for i in input().split()]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
g = 0
for i in l:
	g = gcd(g, i)
print(g * n)


import sys
from bisect import bisect_left, bisect_right
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10
from itertools import permutations
inf = float('inf')
mod = 1000000007
mini = 1000000007

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

def sieve(n):
	prime = [True for i in range(n + 1)]
	lst = []
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p = p + 1
	for i in range(2, n + 1):
		if prime[i]:
			lst.append(i)
	return lst

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			factors.add(n // i)
			n = n // i
			factors.add(i)
	if n > 1:
		factors.add(n)
	return factors

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

def solve(n):
	if n == 1:
		return 1
	p = 2
	while p * p <= n:
		if n % p == 0:
			return n // p
		p = p + 1
	return False

def expo(x, n):
	result = 1
	while n > 1:
		if n & 1:
			n = n - 1
			result = result * x
		else:
			n = n // 2
			x = x * x
	return result * x

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
g = gcd(Arr[0], Arr[1])
for i in range(2, n):
	g = gcd(g, Arr[i])
print(g * n)


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
k = 0
for el in a:
	k = gcd(k, el)
k *= len(a)
print(k)


def GCD(a, b):
	if b == 0:
		return a
	else:
		return GCD(b, a % b)
n = int(input())
lst = list(map(int, input().split()))
rs = lst[0]
for i in range(1, n):
	rs = GCD(rs, lst[i])
print(rs * n)


n = int(input())
l1 = list(map(int, input().split()))
import math
for i in range(n):
	if i == 0:
		x = l1[i]
	else:
		x = math.gcd(x, l1[i])
print(x * n)


n = int(input())
x = list(map(int, input().split()))
while max(x) != min(x):
	x.sort(reverse=True)
	for i in range(n - 1):
		if x[i] > x[i + 1]:
			x[i] -= x[i + 1]
			break
print(sum(x))


from fractions import gcd
from functools import reduce
n = int(input())
l = map(int, input().split())
ans = n * reduce(gcd, l)
print(ans)


import math
n = int(input())
a = list(map(int, input().split()))
for i in range(n - 1):
	t = math.gcd(a[i], a[i + 1])
	(a[i], a[i + 1]) = (t, t)
print(n * min(a))


n = int(input())
nums = set(map(int, input().split()))
while len(nums) > 1:
	max1 = max(nums)
	nums.discard(max1)
	nums.add(max1 - max(nums))
print(int(''.join(list(map(str, nums)))) * n)


n = int(input())
x = list(map(int, input().split()))
while len(x) > 1:
	x.sort()
	l = []
	j = 1
	l.append(x[0])
	while j < n:
		if x[j] > x[j - 1]:
			l.append(x[j] - x[j - 1])
		else:
			l.append(x[j])
		j += 1
	x = l[:]
	if len(set(x)) == 1:
		break
print(sum(x))


n = eval(input())
no = list(map(eval, input().split()))
while True:
	flag = False
	for i in no:
		if i <= 0:
			continue
		for j in range(n):
			if no[j] > i:
				flag = True
				if no[j] % i == 0:
					no[j] = i
				else:
					no[j] = no[j] % i
	if flag == False:
		break
sum = 0
for i in no:
	sum += i
print(int(sum))


import math
from functools import reduce
n = int(input())
line = map(int, input().split())
print(n * reduce(math.gcd, line))


n = int(input())
l = list(map(int, input().split()))
while len(set(l)) > 1:
	l = [x % min(l) * bool(x % min(l)) + bool(not x % min(l)) * min(l) for x in l]
print(sum(l))


import fractions
N = int(input())
X = list(map(int, input().split()))
now = fractions.gcd(X[0], X[1])
for i in range(2, N):
	now = fractions.gcd(now, X[i])
ans = now * N
print(ans)


from math import gcd

def gcd_arr(arr):
	g = arr[0]
	for i in range(1, len(arr)):
		g = gcd(g, arr[i])
	return g
n = int(input().strip())
arr = list(map(int, input().strip().split()))
print(gcd_arr(arr) * n)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	a = LI()
	g = a[0]
	for c in a[1:]:
		g = math.gcd(g, c)
	return g * n
print(main())


n = int(input())
l = list(map(int, input().split()))

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
for i in range(len(l)):
	for j in range(i + 1, n):
		l[i] = l[j] = gcd(l[i], l[j])
print(sum(l))


n = int(input())
a = [int(i) for i in input().split()]
x = 1
while x:
	a = sorted(a)
	x = 0
	for i in range(1, n):
		if a[i] != a[i - 1]:
			x = 1
			a[i] = a[i] - a[i - 1]
print(sum(a))


from fractions import gcd
from functools import reduce
n = int(input())
nums = map(int, input().split())
print(reduce(lambda x, y: gcd(x, y), nums) * n)


from sys import stdin
import math
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
ans = 0
for i in a:
	ans = math.gcd(ans, i)
print(ans * n)


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
while True:
	a.sort()
	k = 0
	for i in range(n - 1):
		if a[i] < a[i + 1]:
			a[i + 1] -= a[i]
			k += 1
	if k == 0:
		break
s = 0
for i in range(n):
	s += a[i]
print(s)


n = int(input())
data = [int(x) for x in input().split()]
data.sort()
while data[0] != data[-1]:
	for i in range(n - 1, 0, -1):
		if data[i] > data[i - 1]:
			data[i] -= data[i - 1]
	data.sort()
print(sum(data))


def nod(a, b):
	while max(a, b) % min(a, b) != 0:
		if a >= b:
			a = a % b
		else:
			b = b % a
	return min(a, b)
n = int(input())
arr = list(map(int, input().split()))
x = arr[0]
for i in range(1, n):
	x = nod(arr[i], x)
print(x * n)


n = int(input())
x = []
m = map(int, input().split())
for k in m:
	x.append(k)
while True:
	mine = x[0]
	for i in range(1, n):
		mine = min(mine, x[i])
	changed = False
	for i in range(n):
		if x[i] > mine:
			x[i] -= mine
			changed = True
	if not changed:
		break
sum = 0
for i in range(n):
	sum += x[i]
print(sum)


from sys import stdin, stdout, stderr, setrecursionlimit
setrecursionlimit(100000)

def debug(*e):
	if not __debug__:
		print(*e, file=stderr)

def dd(*vals):
	import inspect, re
	frame = inspect.getframeinfo(inspect.stack()[1][0])
	vs = re.search('dd\\((.+)\\)', frame.code_context[0]).group(1).split(',')
	if vs:
		debug(','.join(('{0} = {1}'.format(vs[i], v) for (i, v) in enumerate(vals))))

def trace(f):

	def traced(*args, **kw):
		debug('calling {} with args {}, {}'.format(f.__name__, args, kw))
		return f(*args, **kw)
	return traced

def read():
	return stdin.readline().rstrip()

def readarr(sep=None, maxsplit=-1):
	return read().split(sep, maxsplit)

def readint():
	return int(read())

def readia(sep=None, maxsplit=-1):
	return [int(a) for a in readarr(sep, maxsplit)]

def write(*args, **kwargs):
	sep = kwargs.get('sep', ' ')
	end = kwargs.get('end', '\n')
	stdout.write(sep.join((str(a) for a in args)) + end)

def writea(arr, sep=' ', end='\n'):
	stdout.write(sep.join((str(a) for a in arr)) + end)
n = readint()
xs = readia()
while True:
	xs.sort()
	xs.reverse()
	for i in range(1, n):
		if xs[i - 1] > xs[i]:
			xs[i - 1] -= xs[i]
			break
	else:
		write(sum(xs))
		break


import sys
inp = sys.stdin.readlines()
a = int(inp[0])
b = list(map(int, inp[1].split()))

def secondLargest(x):
	i = 0
	while x[0] == x[i] and i < len(x) - 1:
		i += 1
	return i
while True:
	b = sorted(b, reverse=True)
	if b[0] - b[secondLargest(b)] == 0:
		break
	b[0] = b[0] - b[secondLargest(b)]
print(b[0] * a)


x = input()
nums = input().split(' ')
for i in range(len(nums)):
	nums[i] = int(nums[i])
dec = False
while True:
	nums.sort()
	count = 1
	for i in reversed(range(1, len(nums))):
		if nums[i] > nums[i - 1]:
			nums[i] -= nums[i - 1]
		else:
			count += 1
	if count == len(nums):
		break
print(sum(nums))


def log(*args):
	pass
N = int(input())
L = [int(n) for n in input().split()]
assert N == len(L)
L.sort()
changed = True
while changed:
	log('begin, L=', L)
	blah = L[:]
	changed = False
	for i in range(N):
		for j in range(i):
			num = L[i] + L[j]
			if num not in blah:
				blah.append(num)
	log('blah', blah)
	for i in range(N):
		num = L[i]
		for n in range(num - 1, -1, -1):
			if n in blah:
				log('pos', i, 'subtracting', n, 'from', L[i])
				L[i] = num - n
				changed = True
				break
	log(sum(L))
log('fin')
print(sum(L))


n = int(input())
m = list(map(int, input().split()))

def myfunc(m):
	a = min(m)
	for i in range(n):
		m[i] = m[i] % a
		if m[i] == 0:
			m[i] = a
b = m.count(min(m))
if b == n:
	print(m[0] * n)
	exit()
while m.count(min(m)) != n:
	myfunc(m)
print(m[0] * n)


def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	else:
		return gcd(b % a, a)
n = int(input())
l_n = list(map(int, input().split()))
g = gcd(l_n[0], l_n[1])
for i in range(2, n):
	g = gcd(g, l_n[i])
print(g * n)


n = int(input())
x = []
x = input().split()
for i in range(0, n):
	x[i] = int(x[i])
m1 = max(x)
m2 = 0
for i in range(0, n):
	if x[i] > m2 and x[i] != m1:
		m2 = x[i]
while m1 != m2 and m2 != 0:
	i = x.index(m1)
	j = x.index(m2)
	x[i] = x[i] - x[j]
	m1 = max(x)
	m2 = 0
	for i in range(0, n):
		if x[i] > m2 and x[i] != m1:
			m2 = x[i]
print(sum(x))


n = int(input())
nums = list(map(int, input().split()))

def check(nums):
	for i in nums:
		if i != nums[0]:
			return True
	return False
while check(nums):
	nums.sort()
	nums.reverse()
	for i in range(n - 1):
		if nums[i] > nums[i + 1]:
			nums[i] = nums[i] - nums[i + 1]
print(sum(nums))


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	n = ii()
	arr = sorted(li())
	x = arr[0]
	for i in arr[1:]:
		x = gcd(x, i)
	print(x * n)
main()


import math
k = int(input())
l = list(map(int, input().split()))
g = max(l)
for i in l:
	g = math.gcd(g, i)
print(g * k)


def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	if b == 0:
		return a
	return gcd(b, a % b)

def f(l):
	n = len(l)
	g = l[0]
	for i in range(1, n):
		g = gcd(l[i], g)
	return g * n
_ = input()
l = list(map(int, input().split()))
print(f(l))


n = int(input())
l = list(map(int, input().split()))
t = []
for i in range(1, min(l) + 1):
	k = 0
	for j in range(n):
		if l[j] % i == 0:
			k += 1
	if k == n:
		t.append(i)
print(n * max(t))


n = int(input())
a = list(map(int, input().split()))
a.sort()
while True:
	k = 0
	for i in range(n - 1, 0, -1):
		if a[i] > a[i - 1]:
			a[i] = a[i] - a[i - 1]
			k = k + 1
	a.sort()
	if k == 0:
		break
print(sum(a))


from sys import stdin
import math

def equal(arr):
	c = arr[0]
	for i in range(len(arr)):
		if arr[i] != c:
			return False
	else:
		return True
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
while True:
	if equal(arr):
		break
	m = min(arr)
	for i in range(len(arr)):
		if arr[i] % m == 0:
			arr[i] = m
		else:
			arr[i] %= m
print(sum(arr))


n = int(input())
x = [int(i) for i in input().split()]
while 1:
	x.sort(reverse=True)
	num = 0
	i = 0
	while i < len(x):
		for j in range(i + 1, len(x)):
			if x[j] != x[i]:
				num = 1
				for k in range(i, j):
					x[k] = x[k] - x[j]
				i = j
				break
		if j == len(x) - 1:
			break
	if num == 0:
		break
sum = 0
for i in x:
	sum += i
print(sum)


n = int(input())
s = list(map(int, input().split()))
while len(set(s)) > 1:
	x = min(s)
	for i in range(len(s)):
		if s[i] > x:
			s[i] %= x
			if s[i] == 0:
				s[i] = x
print(len(s) * min(s))


n = int(input())
m = [int(k) for k in input().split()]

def g(a, b):
	c = a % b
	if c != 0:
		return c
	else:
		return b

def f(a, b):
	h = []
	for k in a:
		h.append(g(k, b))
	return h
m.sort()
while True:
	if sum(m) != n * m[0]:
		m = f(m, m[0])
		m.sort()
	else:
		break
print(m[0] * n)


n = int(input())
mat = list(map(int, input().split()))
help = set(mat)
while len(help) != 1:
	mat.sort(reverse=True)
	if mat[1] != 0:
		c = min(mat)
		mat[0] -= mat[1]
		if mat[0] == 0:
			mat[0] = c
	else:
		break
	help = set(mat)
print(sum(mat))


from fractions import gcd
(n, val) = (int(input()), 0)
for a in (int(x) for x in input().split()):
	val = a if val == 0 else gcd(val, a)
print(val * n)


import math as m
x = int(input())
y = input().split()
p = y[0]
for i in range(len(y)):
	y[i] = int(y[i])
	p = m.gcd(int(p), int(y[i]))
q = x * p
print(q)


n = int(input())
num = [int(i) for i in input().split()]
num.sort()
J = True
while J:
	J = False
	for i in range(1, n):
		temp = num[i] % num[0]
		if temp == 0:
			num[i] = num[0]
		else:
			num[i] = temp
			J = True
	num.sort()
print(sum(num))


from math import gcd
xx = input()
ls = map(int, input().split())
g = 0
for i in ls:
	g = gcd(g, i)
print(g * int(xx))


n = int(input())
x = list(map(int, input().split()))
done = False
while not done:
	x.sort()
	k = n - 2
	while k >= 0 and x[n - 1] == x[k]:
		k -= 1
	if k < 0:
		done = True
		break
	x[n - 1] -= x[k]
print(sum(x))


from functools import reduce
n = int(input())
k = list(map(int, input().split()))
temp = 0
ans = 0
while True:
	if len(set(k)) == 1:
		break
	k.sort()
	k.reverse()
	for i in range(len(k)):
		for j in range(len(k[i:])):
			if k[i] > k[j]:
				k[i] = k[i] - k[j]
				break
print(reduce(lambda x, y: x + y, k))


import sys
import math

def gcd(a, b):
	if b == 0:
		return a
	r = a % b
	return gcd(b, r)
n = int(sys.stdin.readline())
an = [int(x) for x in sys.stdin.readline().split()]
vmin = min(an)
kmin = 101
for i in range(n):
	t = gcd(vmin, an[i])
	if t < vmin:
		vmin = t
print(n * t)


from math import gcd
n = int(input())
l = list(map(int, input().split()))
gcd1 = 0
for i in l:
	gcd1 = gcd(i, gcd1)
print(n * gcd1)


import math
n = int(input())
l = [int(i) for i in input().split()]
g = l[0]
for i in range(1, n):
	g = math.gcd(g, l[i])
print(g * n)


a = int(input())
p = 0
t = list(map(int, input().split()))
t.sort()
u = t[0]
while len(set(t)) != 1:
	for k in range(a):
		if t[k] % u == 0:
			t[k] = u
		else:
			while u != t[k]:
				if u > t[k]:
					u -= t[k]
				elif t[k] > u:
					t[k] -= u
print(sum(t))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
n = int(input())
x = list(map(int, input().split()))
x.sort()
g = gcd(x[0], x[1])
for i in range(2, n):
	g = gcd(g, x[i])
print(g * n)


N = int(input())
X = sorted(list(map(int, input().split())))
while X.count(X[0]) != N:
	X[-1] -= X[0]
	X = sorted(X)
print(N * X[0])


def gcd1(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def gcdn(l):
	gcd = gcd1(l[0], l[1])
	for i in range(2, len(l)):
		gcd = gcd1(gcd, l[i])
	return gcd
n = int(input())
l = list(map(int, input().split()))
k = gcdn(l)
print(n * k)


def findDiff(values):
	one = values[0]
	for val in values:
		if val != one:
			return True
	return False
n = int(input())
values = input()
values = list(map(int, values.split(' ')))
while findDiff(values):
	curr = min(values)
	maximo = max(values)
	pos = 0
	for i in range(len(values)):
		if values[i] != curr and values[i] <= maximo:
			maximo = values[i]
			pos = i
	values[pos] = values[pos] - curr
print(sum(values))


n = int(input())
ll = input().split()
l = list(map(int, ll))
l.sort()
for i in range(1, n):
	while l[i] != l[0]:
		a = max(l[i] - l[0], l[0])
		b = min(l[i] - l[0], l[0])
		l.pop(0)
		l.insert(0, b)
		l.pop(i)
		l.insert(i, a)
		l.sort()
print(l[0] * n)


n = int(input())
heap = list(map(int, input().split()))
s = 0
dif = 1
i = 0
while dif > 0:
	heap.sort(reverse=True)
	i = 1
	while i < n:
		if heap[0] == heap[i]:
			i += 1
		else:
			break
	if i == n:
		break
	dif = heap[i]
	heap[0] -= dif
print(sum(heap))


n = int(input())
a = list(map(int, input().split()))
while len(set(a)) != 1:
	a.sort(reverse=True)
	for j in range(1, n):
		if a[j - 1] > a[j]:
			a[j - 1] -= a[j]
print(sum(a))


n = int(input())
line = list(map(int, input().split()))
line.sort()
flag = 0
while flag == 0:
	flag = 1
	for i in range(n - 1, 0, -1):
		if line[i] - line[i - 1] > 0:
			line[i] = line[i] - line[i - 1]
			flag = 0
	if flag == 0:
		line.sort()
print(sum(line))


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
from math import floor
mod = 1000000007
INF = float('inf')

def solve():
	n = inp()
	l = li()
	i = 0
	l.sort()
	while i < n:
		f = 0
		for j in range(n):
			if i == j:
				continue
			if l[j] > l[i]:
				l[j] -= l[i] * ((l[j] - 1) // l[i])
				f = 1
		l.sort()
		if f == 0:
			i += 1
	pr(sum(l))
for _ in range(1):
	solve()


from fractions import gcd
n = int(input())
k = 0
l = list(map(int, input().split()))
for i in l:
	k = gcd(k, i)
print(k * n)


from math import gcd
n = int(input())
l = [int(i) for i in input().split()]
d = gcd(l[0], l[1])
for i in range(2, n):
	d = gcd(d, l[i])
print(d * n)


n = int(input().strip())
lst = list(map(int, input().split()))
num = min(lst)
while True:
	for i in range(n):
		if lst[i] % num == 0:
			lst[i] = num
		else:
			lst[i] = lst[i] % num
	if min(lst) == max(lst):
		break
	num = min(lst)
print(sum(lst))


n = int(input())
x = list(sorted(map(int, input().split())))

def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
tgcd = x.pop(0)
for i in x:
	tgcd = gcd(tgcd, i)
print(tgcd * n)


__author__ = 'Utena'
n = int(input())
s = list(map(int, input().split()))
a = s[0]
for i in range(n - 1):
	(a, b) = (max(a, s[i + 1]), min(a, s[i + 1]))
	while True:
		if a % b == 0:
			a = b
			break
		else:
			c = a % b
			a = b
			b = c
print(a * n)


def pairGCD(a, b):
	while a:
		(a, b) = (b % a, a)
	return b

def gcd(l):
	res = l[0]
	for x in l[1:]:
		res = pairGCD(res, x)
	return res
n = int(input())
l = [int(x) for x in input().split()]
print(gcd(l) * n)


import sys, os
from collections import defaultdict
from math import gcd
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))

def main():
	n = int(input())
	arr = read()
	gcd_ = 0
	for i in arr:
		gcd_ = gcd(i, gcd_)
	print(gcd_ * n)
main()


from math import gcd

def play_numbers(lst):
	g = lst[0]
	for i in range(1, len(lst)):
		g = gcd(g, lst[i])
	return g * len(lst)
n = int(input())
a = [int(j) for j in input().split()]
print(play_numbers(a))


def reduce(arr):
	arr.sort(reverse=True)
	if len(set(arr)) == 1:
		return sum(arr)
	found = False
	for i in range(1, len(arr)):
		if arr[i] and arr[i] < arr[0]:
			arr[0] -= arr[i]
			found = True
			break
	if not found:
		return sum(arr)
	return reduce(arr)
n = int(input().strip())
arr = list(map(int, input().strip().split()))
print(reduce(arr))


from math import gcd
n = int(input())
ans = 0
a = input().split()
for i in a:
	ans = gcd(ans, int(i))
print(ans * n)


def gcd(a, b):
	x = max(a, b)
	y = min(a, b)
	if x % y == 0:
		return y
	else:
		return gcd(b, a % b)
n = int(input())
l = list(map(int, input().split()))
a = l[0]
b = l[1]
k = gcd(a, b)
for i in range(2, n):
	k = gcd(k, l[i])
print(k * n)


(n, q) = (int(input()), 0)
import math
for i in map(int, input().split()):
	q = math.gcd(q, i)
print(q * n)


n = int(input())
values = [int(k) for k in input().split()]
while sum(values) != n * min(values):
	for j in range(len(values) - 1):
		for i in range(j + 1, len(values)):
			if values[i] > values[j]:
				values[i] = values[i] - values[j]
			elif values[i] < values[j]:
				values[j] = values[j] - values[i]
			else:
				pass
print(sum(values))


n = int(input())
l = list(map(int, input().split()))
l.sort()

def simple(l):
	done = 0
	for i in range(1, len(l)):
		if l[i] - l[i - 1] != 0:
			done = 1
			break
	if done == 0:
		return False
	return True
x = simple(l)
while x:
	l.sort()
	temp = []
	temp.append(l[0])
	for i in range(1, n):
		if l[i] > l[i - 1]:
			temp.append(l[i] - l[i - 1])
		else:
			temp.append(l[i])
	for i in range(n):
		l[i] = temp[i]
	x = simple(temp)
print(sum(l))


import math
n = int(input())
lst = map(int, input().split())
a = 0
for x in lst:
	a = math.gcd(a, x)
print(a * n)


n = int(input())
a = list(map(int, input().split()))
while 1:
	a.sort()
	for i in range(n - 1):
		if a[len(a) - 1 - i] > a[len(a) - 2 - i]:
			a[len(a) - 1 - i] = a[len(a) - 1 - i] - a[len(a) - 2 - i]
	if a.count(a[0]) == len(a):
		break
print(sum(a))


n = int(input())
v = list(map(int, input().split()))

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
g = v[0]
for each_v in v:
	g = gcd(g, each_v)
print(g * n)


from collections import deque
import math
import bisect
n = int(input())
list1 = list(map(int, input().split()))
x = math.gcd(list1[0], list1[1])
for i in range(2, n):
	x = math.gcd(x, list1[i])
print(x * n)


def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
n = int(input())
ins = input().split(' ')
min = int(ins[0])
for i in range(1, n):
	min = gcd(min, int(ins[i]))
print(str(n * min))


n = int(input())
a = list(map(int, input().split()))
while 1:
	T = True
	for i in range(n):
		for j in range(n):
			if a[i] > a[j]:
				a[i] = a[i] - a[j]
				T = False
			elif a[i] < a[j]:
				a[j] = a[j] - a[i]
				T = False
	if T:
		break
print(sum(a))


n = int(input())
l = list(map(int, input().split()))
while len(set(l)) != 1:
	m = min(l)
	for i in range(n):
		if l[i] != m:
			if l[i] % m != 0:
				l[i] = l[i] - m * (l[i] // m)
			else:
				l[i] = m
print(sum(l))


a = int(input())
b = [int(b) for b in input().split()]
b.sort()
c = 0
for i in range(a):
	for j in range(a):
		while b[i] < b[j]:
			b[j] = b[j] - b[i]
		while b[i] > b[j]:
			b[i] = b[i] - b[j]
for i in range(a):
	for j in range(a):
		while b[i] < b[j]:
			b[j] = b[j] - b[i]
		while b[i] > b[j]:
			b[i] = b[i] - b[j]
for i in range(a):
	c = c + b[i]
print(c)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
mdc = arr[0]
for i in arr[1:]:
	if mdc < i:
		aux = mdc
		mdc = i
		i = aux
		while i != 0:
			aux = i
			i = mdc % i
			mdc = aux
print(mdc * n)


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
k = 1
while k:
	k = 0
	for i in range(1, len(b)):
		if b[i] - b[0] > 0:
			if b[i] % b[0] > 0:
				b[i] = b[i] % b[0]
			else:
				b[i] = b[0]
			k = 1
	b = sorted(b)
print(sum(b))


n = int(input())
x = [int(i) for i in input().split()]
while True:
	tmp = min(x)
	for i in range(n):
		if x[i] % tmp == 0:
			x[i] = tmp
		else:
			x[i] %= tmp
	if sum(x) == tmp * n:
		break
print(sum(x))


n = int(input())
arr = list(map(int, input().split()))
res = sum(arr)
while True:
	m = min(arr)
	for i in range(n):
		if arr[i] > m:
			arr[i] -= m
	if res > sum(arr):
		res = sum(arr)
	else:
		break
print(res)


import math
n = int(input())
x = list(map(int, input().split()))
y = x[0]
for i in x[1:]:
	y = math.gcd(y, i)
print(y * n)


N = int(input())
fox_numbers = list(map(int, input().split()))
if list(set(fox_numbers)) == 1:
	print(sum(fox_numbers))
else:
	answer = []
	times = 0
	while True:
		if len(answer) > 1 and all((e == answer[0] for e in answer)):
			break
		elif times == 1:
			times = 0
			fox_numbers = answer.copy()
			answer = []
		for i in range(N):
			idx = -1
			for j in range(N):
				if i == j:
					continue
				if fox_numbers[i] > fox_numbers[j]:
					idx = j
			if idx > -1:
				answer.append(fox_numbers[i] - fox_numbers[idx])
			else:
				answer.append(fox_numbers[i])
		times += 1
	print(sum(answer))


def fox_and_number_game(n_int: int, numbers_list: list) -> int:
	numbers_list.sort(reverse=True)
	while numbers_list[0] > numbers_list[-1]:
		largest_2nd_idx = 1
		while numbers_list[0] == numbers_list[largest_2nd_idx]:
			largest_2nd_idx += 1
		numbers_list[0] = numbers_list[0] - numbers_list[largest_2nd_idx]
		numbers_list.sort(reverse=True)
	return sum(numbers_list)
n = int(input())
numbers = list(map(int, input().split()))
print(fox_and_number_game(n, numbers))


def gcd(x, y):
	if x % y == 0:
		return y
	elif y % x == 0:
		return x
	elif x > y:
		return gcd(x % y, y)
	elif y > x:
		return gcd(y % x, x)
n = int(input())
inp = list(map(int, input().split()))
k = inp[0]
for i in range(0, len(inp) - 1):
	k = gcd(k, inp[i + 1])
print(len(inp) * k)


def minimal(l):
	x = min(l)
	for i in range(x, 1, -1):
		for j in l:
			if j % i != 0:
				break
		else:
			return i
	return 1
n = int(input())
l = [int(i) for i in input().split()]
print(n * minimal(l))


def nod(x, y):
	while x * y:
		if x > y:
			x %= y
		else:
			y %= x
	return x + y
n = int(input())
a = list(map(int, input().split()))
m = a[0]
for i in range(1, n):
	m = nod(m, a[i])
print(n * m)


import math
n = int(input())
l = list(map(int, input().split()))
ans = 0
test = 0

def typo():
	l.sort()
	l.reverse()
	for i in range(n):
		for j in range(i, n):
			if l[i] - l[j] > 0:
				l[i] -= l[j]
				break
for i in range(100):
	typo()
for i in range(n):
	ans += l[i]
print(ans)


bot = True
from fractions import gcd
(n, a) = (int(input()), 0)
for i in map(int, input().split()):
	a = gcd(i, a)
print(n * a)


n = int(input())
arr = list(map(int, input().split()))
while len(set(arr)) > 1:
	x = max(arr)
	y = min(arr)
	arr.append(x - y)
	arr.remove(x)
print(sum(arr))


n = int(input())
array = list(map(int, input().split()))
array.sort()
b = 1
for i in range(max(array) - min(array) + n + 1):
	for j in range(1, n):
		if array[j] > array[0]:
			array[j] = array[j] - array[0]
			array.sort()
print(sum(array))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
readint = lambda : int(sys.stdin.readline().rstrip('\r\n'))
readints = lambda : map(int, sys.stdin.readline().rstrip('\r\n').split())
readstr = lambda : sys.stdin.readline().rstrip('\r\n')
readstrs = lambda : map(str, sys.stdin.readline().rstrip('\r\n').split())
readarri = lambda : [int(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
readarrs = lambda : [str(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]

def solve():
	(n, arr) = (readint(), readarri())
	while 1:
		if len(set(arr)) == 1:
			print(sum(arr))
			return
		(p1, p2) = (-1, -1)
		for i in range(n):
			for j in range(n):
				if arr[j] != arr[i]:
					p2 = j
					p1 = i
					break
			if p1 != -1:
				break
		while 1:
			if arr[p1] == arr[p2] or arr[p1] == 0 or arr[p2] == 0:
				break
			if arr[p1] > arr[p2]:
				arr[p1] -= arr[p2]
			if arr[p2] > arr[p1]:
				arr[p2] -= arr[p1]

def main():
	t = 1
	for _ in range(t):
		solve()
main()


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
for _ in range(num):
	n = int(z())
	arr = szzz()
	ans = arr[0]
	for i in arr:
		ans = gcd(ans, i)
	print(ans * n)


import sys
sys.setrecursionlimit(1500)

def fun(list):
	list = sorted(list)
	(c, d, i) = (list[0], len(list), 1)
	if list.count(c) == d:
		return list
	else:
		list = sorted(list)
		while i < d:
			if list[i] == c:
				i = i + 1
				continue
			else:
				list[i] = list[i] - c
				i = i + 1
		return fun(list)
(a, list) = (int(input()), [int(x) for x in input().split()])
print(sum(fun(list)))


from math import gcd
x = input()
size = map(int, input().split())
g = 0
for i in size:
	g = gcd(g, i)
print(g * int(x))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
n = int(input())
numbers = list(map(int, input().split(' ')))
ans = 0
for i in numbers:
	ans = gcd(ans, i)
print(n * ans)


from fractions import gcd
n = int(input())
arr = map(int, input().split())
j = next(arr)
for i in arr:
	j = gcd(i, j)
print(n * j)


from functools import reduce
n = int(input())
m = [*map(int, input().split())]
m = sorted(m, reverse=True)

def g_d_c(n1, n2):
	if n2 == 0:
		return n1
	else:
		return g_d_c(n2, n1 % n2)
gcd = reduce(lambda x, y: g_d_c(x, y), m)
print(gcd * n)


n = int(input())
mat = list(map(int, input().split()))

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
k = gcd(mat[0], mat[1])
for i in range(2, len(mat)):
	k = gcd(k, mat[i])
print(k * n)


import math
from functools import reduce
n = int(input())
data = [int(x) for x in input().split()]
print(reduce(lambda x, y: math.gcd(x, y), data) * n)


from fractions import gcd
n = int(input())
x = []
m = map(int, input().split())
for k in m:
	x.append(k)
g = x[0]
for i in range(1, n):
	g = gcd(g, x[i])
print(g * n)


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
found = True
while found is True:
	found = False
	for i in range(n):
		max_j = None
		for j in range(n):
			if i != j and arr[i] > arr[j] and (max_j is None or arr[j] > arr[max_j]):
				max_j = j
		if max_j is not None:
			found = True
			arr[i] -= arr[max_j]
print(sum(arr))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	while a[n - 1] > a[0]:
		for i in range(n):
			if not a[i] % a[0] == 0:
				a[i] = a[i] % a[0]
			else:
				a[i] = a[0]
		a.sort()
	print(sum(a))
try:
	solve()
except:
	pass


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n = int(input())
arr = list(map(int, input().split()))
done = False
while not done:
	arr.sort(reverse=True)
	changed = False
	for i in range(1, n):
		if arr[i - 1] > arr[i]:
			arr[i - 1] = arr[i - 1] - arr[i]
			changed = True
	if not changed:
		done = True
print(sum(arr))


from math import gcd
n = int(input())
vetor = list(map(int, input().split()))
comum = gcd(vetor[0], vetor[1])
for i in range(2, n):
	comum = gcd(comum, vetor[i])
resp = comum * n
print(resp)


import math
n = int(input())
l = list(map(int, input().split()))
s = 0
for i in l:
	s = math.gcd(s, i)
print(n * s)


n = int(input())
list = [int(i) for i in input().split()]
while min(list) != max(list):
	list.sort()
	for i in range(1, n):
		if list[i] > list[0]:
			list[i] -= list[0]
print(sum(list))


def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)
n = int(input())
arr = list(map(int, input().split()))
res = arr[0]
for ele in arr:
	res = gcd(res, ele)
print(n * res)


n = int(input())
t = [int(i) for i in input().split()]
while min(t) != max(t):
	k = min(t)
	for i in range(n):
		if t[i] > k:
			t[i] = t[i] % k
			if t[i] == 0:
				t[i] = k
s = n * t[0]
print(s)


from fractions import gcd
n = int(input())
a = [int(x) for x in input().split()]
x = a[0]
for i in range(1, n):
	x = gcd(x, a[i])
print(x * len(a))


input().split()
xs = list(map(int, input().split()))

def gdc(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
ret = 0
for x in xs:
	ret = gdc(x, ret)
print(ret * len(xs))


def gcd(X, Y):
	(X, Y) = (min(X, Y), max(X, Y))
	if X == 0:
		return Y
	return gcd(Y % X, X)

def F(l):
	A = l[0]
	for E in l:
		A = gcd(A, E)
	return A * len(l)
n = int(input())
a = list(map(int, input().split()))
print(F(a))


n = int(input())
arr = list(map(int, input().split()))
while max(arr) > min(arr):
	index = arr.index(max(arr))
	arr[index] -= min(arr)
print(sum(arr))


from math import gcd
n = int(input())
A = list(map(int, input().split()))
j = A[0]
for i in A:
	j = gcd(j, i)
print(j * n)


import copy
n = int(input())
x = list(map(int, input().split()))
x = sorted(x)
y = []
while x[0] != x[-1]:
	for i in range(n - 1):
		if x[-i - 1] > x[-i - 2]:
			y.append(x[-i - 1] - x[-i - 2])
		else:
			y.append(x[-i - 1])
	y.append(x[0])
	x = copy.copy(y)
	x = sorted(x)
	y = []
print(x[0] * n)


n = int(input())
numbers = list(map(int, input().split()))
a = numbers[0]
b = numbers[1]
for i in range(1, n):
	b = numbers[i]
	while a != b:
		if a > b:
			a -= b
		else:
			b -= a
print(n * a)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
n = int(input())
a = [int(i) for i in input().split()]
x = a[0]
for i in range(1, n):
	x = gcd(x, a[i])
print(x * n)


n = int(input())
l = sorted(list(map(int, input().split())))
for i in range(n):
	for j in range(i + 1, n):
		while l[j] - l[i] > 0:
			l[j] = l[j] - l[i]
			l.sort()
print(sum(l))


num = int(input())
numbers = list(map(int, input().split()))
for x in range(101):
	for y in range(num):
		for z in range(num):
			if numbers[y] > numbers[z]:
				numbers[y] = numbers[y] - numbers[z]
print(sum(numbers))


n = int(input())
x = list(map(int, input().split()))
while True:
	x.sort()
	if x[-2] == 0:
		print(x[-1] * n)
		exit()
	else:
		x[-1] = x[-1] - x[-2]


def hcf(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
n = int(input())
l = list(map(int, input().split()))
h = hcf(l[0], l[1])
for i in range(2, n):
	h = hcf(h, l[i])
print(h * n)


import math
n = int(input())
a = list(map(int, input().split()))
common_gcd = math.gcd(a[0], a[1])
for i in range(2, n):
	common_gcd = math.gcd(common_gcd, a[i])
print(common_gcd * n)


from fractions import gcd
a = int(input())
nums = list(map(int, input().split(' ')))
gcdx = nums[0]
for i in range(len(nums)):
	gcdx = gcd(gcdx, nums[i])
print(gcdx * a)


def g(x):
	if len(x) == 1:
		return x[0]
	if x[0] == 0:
		return g(x[1:])
	return g([x[-1] % x[0]] + x[:-1])
input()
a = list(map(int, input().split()))
print(g(a) * len(a))


def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
n = int(input())
a = list(map(int, input().split()))
s = gcd(a[0], a[1])
for i in range(2, n):
	s = gcd(s, a[i])
print(s * n)


n = int(input())
l = list(map(int, input().split()))
while True:
	o = min(l)
	if all([i == o for i in l]):
		break
	for j in range(len(l)):
		if l[j] != o:
			l[j] -= o
print(sum(l))


firstEntry = True
codeNotDone = True
sameList = False
numofNums = int(input())
numbersGiven = []
numbersGiven = input().split(' ')
for i in range(0, len(numbersGiven)):
	numbersGiven[i] = int(numbersGiven[i])
	if numbersGiven[i] == 1 and codeNotDone:
		codeNotDone = False
		print(numofNums)
while codeNotDone and (not sameList):
	if not firstEntry:
		numbersGiven = n
	else:
		firstEntry = False
	n = sorted(numbersGiven)
	if n[0] == n[-1]:
		sameList = True
	while n[-1] > n[0]:
		n[-1] = n[-1] - n[0]
if codeNotDone:
	print(n[0] * numofNums)


from math import gcd
from functools import reduce

def find_gcd(l):
	x = reduce(gcd, l)
	return x

class CodeforcesTask389ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.nums = []

	def read_input(self):
		self.n = int(input())
		self.nums = [int(x) for x in input().split(' ')]

	def process_task(self):
		self.result = str(self.n * find_gcd(self.nums))

	def get_result(self):
		return self.result
Solution = CodeforcesTask389ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()

def gcd(a, b):
	if a == 0:
		return b
	else:
		return gcd(b % a, a)
n = int(input())
Arr = get_array()
g = Arr[0]
for i in range(1, n):
	g = gcd(g, Arr[i])
print(g * n)


k = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
for i in range(1000):
	for i in range(k - 1):
		if l[i + 1] < l[i]:
			l[i] -= l[i + 1]
			l.sort(reverse=True)
print(sum(l))


m = int(input())
l = list(map(int, input().split()))
l = list(set(l))
l.sort(reverse=True)
n = len(l)
while n > 1:
	l[0] -= l[1]
	for i in range(n - 1):
		if l[i] < l[i + 1]:
			(l[i], l[i + 1]) = (l[i + 1], l[i])
		else:
			break
	if l[i] == l[i + 1]:
		del l[i]
		n -= 1
print(m * l[0])


from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
no = a[0]
for i in range(1, n):
	no = gcd(no, a[i])
print(no * n)


n = int(input())
s = [int(x) for x in input().split()]
r = s[0]

def gcd(t, p):
	while p:
		(t, p) = (p, t % p)
	return t
for i in s[1:]:
	r = gcd(max(r, i), min(r, i))
print(r * len(s))


from fractions import gcd
from functools import reduce
print(int(input()) * reduce(gcd, [int(x) for x in input().split()]))


n = int(input())
l = list(map(int, input().split()))
l.sort()
while l[0] != l[n - 1]:
	j = int(n - 1)
	while j > 0:
		if l[j] > l[j - 1]:
			l[j] = l[j] - l[j - 1]
		j -= 1
	l.sort()
print(sum(l))


import math
n = int(input())
array = input().split(' ')
for i in range(n):
	array[i] = int(array[i])
answer = array[0]
for i in range(1, n):
	answer = math.gcd(answer, array[i])
print(answer * n)


def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
n = int(input())
arr = list(map(int, input().split()))
ans = arr[0]
for i in range(1, n):
	ans = find_gcd(ans, arr[i])
print(ans * n)


def GCD(x, y):
	while x != y:
		if x < y:
			(x, y) = (y, x)
		x -= y
	return x
n = int(input())
ar = list(map(int, input().split(' ')))
r = ar[0]
for i in range(n - 1):
	r = GCD(r, ar[i + 1])
print(r * n)


from math import gcd
(n, x) = (int(input()), 0)
for i in map(int, input().split()):
	x = gcd(i, x)
print(n * x)


import math
n = int(input())
l = list(map(int, input().split()))
ans = l[0]
i = 1
while i < len(l):
	ans = math.gcd(ans, l[i])
	i = i + 1
print(ans * n)


N = int(input())
from math import *
A = list(map(int, input().split()))
if N == 1:
	print(A[0])
else:
	g = gcd(A[0], A[1])
	for i in range(2, N):
		g = gcd(g, gcd(A[i], A[i - 1]))
	print(g * N)


n = int(input())
num = input().split()
num = [int(x) for x in num]
while max(num) != min(num):
	maior = num.index(max(num))
	num[maior] -= min(num)
soma = 0
for n in num:
	soma += n
print(soma)


import math
l = int(input(''))
s = input()
l1 = s.split(' ')
l1 = list(map(int, l1))
l2 = l1
l3 = []
while True:
	l1 = l2
	l2 = sorted(l2)
	x = len(l1) - 1
	while x > 0:
		if l2[x] > l2[x - 1]:
			l2[x] = l2[x] - l2[x - 1]
		x -= 1
	l3.append(sum(l2))
	if l1 == l2:
		break
print(min(l3))


import math
from collections import defaultdict

def input_ints():
	return list(map(int, input().split()))

def solve():
	n = int(input())
	a = input_ints()
	x = a[0]
	for y in a:
		x = math.gcd(x, y)
	print(n * x)
solve()


def gcd(x, y):
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)
n = int(input())
x = list(map(int, input().split()))
g = x[0]
for i in range(len(x)):
	g = gcd(g, x[i])
print(g * len(x))


from functools import reduce
n = int(input())
numbers = list(map(int, input().split()))
numbers.sort()

def gcd(a, b):
	while b % a != 0:
		(a, b) = (b % a, a)
	return a
print(n * reduce(gcd, numbers))


n = int(input())
l1 = list(map(int, input().split()))
i = min(l1)
c = 0
while i >= 1:
	c = 0
	for x in l1:
		if x % i == 0:
			c = c + 1
	i = i - 1
	if c == n:
		break
print((i + 1) * n)


n = int(input())
number = [int(i) for i in input().split()]
m = 1
for i in range(2, min(number) + 1):
	for j in number:
		if j % i != 0:
			break
		if j == number[-1]:
			m = i
print(n * m)


n = int(input())
k = list(map(int, input().split()))
k = sorted(k)
r = []
for i in k:
	if i not in r:
		r.append(i)
r = sorted(r)
if len(r) == 1:
	print(len(k) * k[0])
elif len(r) == 2:
	while r[0] != r[1]:
		r.append(r[1] - r[0])
		r = sorted(r)
		r.remove(r[-1])
	print(len(k) * r[0])
elif len(k) == 3:
	s = []
	for h in range(1, len(k)):
		if k[h] % k[0] != 0:
			s.append(len(k))
		else:
			t = []
			for w in range(1, len(r)):
				t.append(r[w] - r[w - 1])
			s.append(min(t) * len(k))
	print(min(s))
elif len(r) > 3:
	t = []
	for w in range(1, len(r)):
		t.append(r[w] - r[w - 1])
	print(min(t) * len(k))


from math import *
n = int(input())
l = list(map(int, input().strip().split()))
l.sort()
gcd_value = l[0]
for i in range(1, len(l)):
	gcd_value = gcd(gcd_value, l[i])
print(gcd_value * n)


def gcd(a, b):
	return b == 0 and a or gcd(b, a % b)
n = int(input())
x = list(map(int, input().split()))
i = 0
for i in range(n):
	x[0] = gcd(x[0], x[i])
print(n * x[0])