#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
const int INF = 0x3f3f3f3f;
int n;
int a[2 * maxn];
long long ans;
int main() {
  scanf("%d", &n);
  int minval = INF;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i + n] = a[i];
    minval = min(a[i], minval);
  }
  ans = (long long)minval * n;
  int AddLength = 0;
  int MaxLength = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (a[i] > minval) {
      AddLength++;
    } else {
      MaxLength = max(AddLength, MaxLength);
      AddLength = 0;
    }
  }
  ans += MaxLength;
  cout << ans << endl;
  return 0;
}
