#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> paints(n);
  int minpaint = 1000000001;
  for (int i = 0; i < n; i++) {
    scanf("%d", &paints[i]);
    minpaint = min(minpaint, paints[i]);
  }
  int maxseg = 0;
  int firstseg = -1;
  int lastseg = -1;
  int seglength = 0;
  for (int i = 0; i < n; i++) {
    if (paints[i] == minpaint) {
      maxseg = max(maxseg, seglength);
      if (firstseg == -1) firstseg = seglength;
      if (firstseg != -1) lastseg = seglength;
      seglength = 0;
    } else {
      seglength++;
    }
  }
  if (seglength) {
    maxseg = max(maxseg, seglength);
    lastseg = seglength;
  }
  if (firstseg != -1)
    if (paints[0] != minpaint && paints[n - 1] != minpaint) {
      maxseg = max(maxseg, firstseg + (lastseg != -1 ? lastseg : 0));
    }
  printf("%lld\n", ((long long)minpaint) * n + maxseg);
  return 0;
}
