#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0, a = 0, x = 0, f = 0, sum = 0, g = 0;
  cin >> n;
  int num[n];
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  while (1) {
    x = 0;
    a = 0;
    g = num[0];
    for (int i = 0; i < n; i++) {
      if (num[i] > x) {
        x = num[i];
        c = i;
      }
    }
    for (int b = 0; b < n; b++) {
      if (num[b] > a && num[b] < x) {
        a = num[b];
        f = b;
        g = a;
      }
    }
    if (g == x)
      break;
    else
      num[c] = num[c] - num[f];
  }
  for (int i = 0; i < n; i++) sum = sum + num[i];
  cout << sum << endl;
  return 0;
}
