#include <bits/stdc++.h>
using namespace std;
const int m1 = 1001000;
const int m2 = 1010;
int head[m1], vex[m1], arr[m1];
bool vis[110];
int a[3 * 200000];
int main() {
  int n, m, i, j, k;
  while (~scanf("%d", &n)) {
    int mi = 0x3f3f3f3f;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      mi = min(mi, a[i]);
      a[i + n] = a[i];
    }
    int ma = 0;
    int j = 0;
    for (i = 0; i <= 2 * n; i++) {
      if (a[i] == mi) {
        ma = max(i - j, ma);
        j = i;
      }
    }
    printf("%lld\n", 1ll * n * mi + ma - 1);
  }
  return 0;
}
