#include <bits/stdc++.h>
using namespace std;
long long int arr[200000];
int main() {
  long long int n, m, lmin, rmin;
  cin >> n;
  m = 1000000000000;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    m = min(m, arr[i]);
  }
  bool ok = 1;
  long long int out = -10000000000;
  int lastmin;
  for (int i = 0; i < n; i++) {
    if (arr[i] == m && ok)
      lmin = i, ok = 0, lastmin = i;
    else if (arr[i] == m) {
      out = max(out, 1LL * i - lastmin);
      lastmin = i;
    };
  }
  out = max(out - 1, n - (lastmin - lmin + 1));
  out += n * m;
  cout << out;
}
