#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ar[n];
  long long rez = 0;
  for (int ctr1 = 0; ctr1 < n; ctr1++) cin >> ar[ctr1];
  int mi = ar[0];
  for (int ctr1 = 1; ctr1 < n; ctr1++) mi = min(mi, ar[ctr1]);
  for (int ctr1 = 0; ctr1 < n; ctr1++) ar[ctr1] -= mi;
  rez = 1LL * mi * n;
  int left = 0;
  int cur = 0;
  for (int ctr1 = 0; ctr1 < 2 * n; ctr1++) {
    if (ar[ctr1 % n] > 0)
      cur++;
    else
      cur = 0;
    if (cur > left) left = cur;
  }
  cout << rez + left << endl;
  return 0;
}
