#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  int a[200000];
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int min = a[0];
  for (i = 1; i < n; i++) {
    if (a[i] < min) min = a[i];
  }
  for (i = 0; i < n; i++) {
    a[i] -= min;
  }
  int count;
  int max = 0;
  count = 0;
  int one = 1;
  i = 0;
  while (i < n) {
    if (a[i] == 0) {
      if (count > max) max = count;
      count = 0;
    } else {
      count++;
    }
    if (one && i == n - 1) {
      i = 0;
      one = 0;
    } else {
      i++;
    }
  }
  long long result = (long long)max + (long long)min * (long long)n;
  printf("%lld", result);
  return 0;
}
