#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double eps = 1e-9;
const double pi = acos(-1.0);
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  while (true) {
    sort(a.begin(), a.end());
    bool ok = false;
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] < a[n - 1]) {
        a[n - 1] = a[n - 1] - a[i];
        ok = true;
        break;
      }
    }
    if (!ok) break;
  }
  cout << accumulate(a.begin(), a.end(), 0) << endl;
  return 0;
}
