#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, A[(int)2e5 + 10], min = INT_MAX, max = 0, cnt = 0, r;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", A + i);
    if (min > A[i]) {
      min = A[i], r = i;
    }
  }
  for (int i = (r + 1) % n; i != r; i = (i + 1) % n) {
    if (min == A[i])
      cnt = 0;
    else
      cnt++;
    if (max < cnt) max = cnt;
  }
  printf("%lld", 1ll * n * min + max);
  return 0;
}
