#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<unsigned long long int> nums(n);
  unsigned long long int miVal = INT_MAX;
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
    miVal = min(miVal, nums[i]);
  }
  for (int i = 0; i < n; i++) {
    nums[i] -= miVal;
  }
  unsigned long long int res = miVal * n;
  unsigned long long int cLen = 0, mxLen = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (nums[i % n] == 0) {
      mxLen = max(mxLen, cLen);
      cLen = 0;
    } else {
      cLen++;
    }
  }
  res += mxLen;
  cout << res;
}
