#include <iostream>
using namespace std;
//先定义求解最大公约数的函数gcd
int gcd(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
a[i] = temp;
}//定义并赋值给数组
long long first = a[0];//这边需要用longlong,不然栈会溢出
for (int i = 1; i < n; i++) {
first = gcd(first, a[i]);
}//数组第一个元素作为载体存储依次所有元素的最大公约数
cout << first* n << endl;
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号