#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, *a, i, period, p, min_val = INT_MAX, max_period = 0;
  bool was = false;
  cin >> n;
  a = new long long[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    min_val = (min_val < a[i] ? min_val : a[i]);
  }
  period = 0;
  p = 0;
  for (i = 0; i < 2 * n; i++) {
    if (a[p] == min_val) {
      if (was) {
        max_period = (max_period > period ? max_period : period);
        period = 0;
      } else {
        was = true;
      }
    } else if (was) {
      period++;
    }
    if (++p == n) {
      p = 0;
    }
  }
  cout << (min_val * n) + max_period << endl;
}
