#include <bits/stdc++.h>
using namespace std;
struct p {
  int x;
  int i;
} a[200123];
int cmp(p a, p b) {
  if (a.x != b.x)
    return a.x < b.x;
  else
    return a.i < b.i;
}
int main() {
  int n;
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i].x);
    a[i].i = i;
  }
  sort(a, a + n, cmp);
  int mi = 0;
  long long y = 0;
  i = 1;
  while (i < n && a[i].x == a[0].x) {
    if (a[i].i - a[i - 1].i - 1 > mi) mi = a[i].i - a[i - 1].i - 1;
    i++;
  }
  if (a[0].i + n - a[i - 1].i - 1 > mi) mi = a[0].i + n - a[i - 1].i - 1;
  y = (long long)a[0].x * n + mi;
  printf("%lld\n", y);
  return 0;
}
