#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> s;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert(a[i]);
  }
  int sum = 0;
  sort(a, a + n);
  auto it = s.begin();
  while (s.size() != 1 && *it != 0) {
    for (int i = 1; i < n; i++) {
      int m = a[i];
      while (a[i] > a[0]) a[i] = a[i] - a[0];
      s.insert(a[i]);
      s.erase(m);
    }
    sort(a, a + n);
  }
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  cout << sum << endl;
}
