#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long arr[200005];
  long long mini = 1000000005;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    if (arr[i] < mini) {
      mini = arr[i];
    }
  }
  for (int i = 0; i < n; i++) {
    arr[i] -= mini;
  }
  int ls = -1;
  int cs = -1;
  int len = 0;
  int ml = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] > 0) {
      len++;
      if (len == 1) {
        cs = i;
      }
      if (len > ml) {
        ml = len;
        ls = cs;
      }
    } else {
      len = 0;
      cs = -1;
    }
  }
  long long l1 = 0;
  bool done = false;
  int p = 0;
  while (!done) {
    if (arr[p] > 0) {
      l1++;
      p++;
    } else {
      done = true;
    }
  }
  done = false;
  p = n - 1;
  while (!done) {
    if (arr[p] > 0) {
      l1++;
      p--;
    } else {
      done = true;
    }
  }
  if (l1 > ml) {
    ml = l1;
  }
  long long ans = n * mini;
  ans += ml;
  printf("%lld\n", ans);
}
