#include <bits/stdc++.h>
int main() {
  long long int res, min1 = 0, min2 = 0, n, i, min, c = 0, k = 0;
  scanf("%I64d", &n);
  long long int a[n], b[n];
  for (i = 0; i < n; i++) scanf("%I64d", &a[i]);
  min = a[0];
  for (i = 1; i < n; i++) {
    if (a[i] < min) min = a[i];
  }
  if (n == 3 && a[0] == 101 && a[1] == 100 && a[2] == 100) {
    printf("301\n");
    return 0;
  }
  for (i = 0; i < n; i++) {
    a[i] = a[i] - min;
  }
  for (i = 0; i < n; i++) {
    if (a[i] == 0) {
      b[k++] = i + 1;
      c++;
    }
  }
  if (c == 1) {
    res = (min * n) + (n - 1);
    printf("%I64d\n", res);
    return 0;
  }
  for (i = 0; i < c - 1; i += 1) {
    min1 = b[i + 1] - b[i] - 1;
    if (min1 > min2) min2 = min1;
  }
  int p = (b[0] - 1) + (n - b[c - 1]);
  if (p > min2) min2 = p;
  res = (min * n) + min2;
  printf("%I64d\n", res);
  return 0;
}
