#include <bits/stdc++.h>
int main(int argc, const char* argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> v(n);
  for (int i = 0; i < n; i++) std::cin >> v[i];
  std::sort(v.begin(), v.end(), std::greater<int>());
  while (true) {
    bool find = false;
    for (int j = 1; j < n; j++) {
      while (v[0] > v[j]) {
        v[0] -= v[j];
        find = true;
      }
    }
    std::sort(v.begin(), v.end(), std::greater<int>());
    if (!find) break;
  }
  int result = 0;
  for (int i = 0; i < n; i++) result += v[i];
  std::cout << result << std::endl;
  return 0;
}
