#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long minn = 1000000007, maxx = 0, maxxx = 0;
  long long gap = 0, front = -1, flag = 0, first, last;
  for (int i = 0; i < n; i++) {
    if (a[i] < minn) minn = a[i];
    if (a[i] > maxxx) maxxx = a[i];
  }
  if (minn == maxxx) {
    cout << minn * n;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    a[i] -= minn;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      first = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      last = i;
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      if (front == -1) {
        front = i;
        gap = 0;
        continue;
      }
      flag = 1;
      gap = i - front;
      front = i;
      if (gap > maxx) {
        maxx = gap;
      }
    }
  }
  long long gap2 = last - first;
  gap2 = n - gap2;
  if (gap2 > maxx) maxx = gap2;
  if (flag == 0)
    cout << minn * n + n - 1;
  else
    cout << minn * n + maxx - 1;
  return 0;
}
