#include <bits/stdc++.h>
using namespace std;
long long int arr[200005];
int main() {
  ios::sync_with_stdio(false);
  long long int n, i;
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  long long int mini = 1000000001;
  for (i = 0; i < n; i++) {
    if (mini > arr[i]) mini = arr[i];
  }
  int k = 0;
  for (i = 0; i < n; i++) {
    if (arr[i] == mini) {
      k++;
    }
  }
  long long int mult;
  if (k == 1) {
    mult = ((n * mini) + n - 1);
    cout << mult;
  } else if (k == n) {
    mult = n * mini;
    cout << mult;
  } else {
    long long int first = -1, curr, dist = 0, prev;
    for (i = 0; i < n; i++) {
      if (arr[i] == mini) {
        if (first == -1) {
          prev = i;
          first = i;
        } else {
          curr = i;
          if (dist < curr - (prev + 1)) dist = curr - (prev + 1);
          prev = curr;
        }
      }
    }
    if (dist < (n - 1 + first) - curr) dist = (n - 1 + first) - curr;
    mult = ((n * mini) + dist);
    cout << mult;
  }
  return 0;
}
