#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) {
  if (a > b)
    return true;
  else
    return false;
}
int main() {
  int n;
  while (cin >> n) {
    int arr[3050];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    while (1) {
      bool b = false;
      sort(arr, arr + n, cmp);
      int mmin = 100000, minpos = -1;
      for (int i = 0; i < n - 1; i++) {
        if (arr[i] - arr[i + 1] < mmin && arr[i] - arr[i + 1] > 0) {
          b = true;
          mmin = arr[i] - arr[i + 1];
          minpos = i;
        }
      }
      if (b) {
        arr[minpos] = mmin;
      } else
        break;
    }
    int sum = 0;
    for (int i = 0; i < n; i++) sum += arr[i];
    cout << sum << endl;
  }
  return 0;
}
