#include <iostream> #include <algorithm> #include <vector> #include <numeric> using namespace std; int main(){ int n; cin >> n; vector<int> x(n,0); for(int i = 0 ; i < n; ++ i ){ cin >> x[i]; } bool flag = true; while(flag){ flag = false; sort(x.begin(),x.end()); for(int i = n - 1; i >=1; i -- ){ if(x[i]-x[i-1] > 0){ x[i]-=x[i-1]; flag = true; } } } cout<<accumulate(x.begin(),x.end(),0)<<endl; return 0; }