#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long int> paint;
  long long int minim = 9999999999;
  for (int i = 0; i < n; i++) {
    long long int tmp;
    cin >> tmp;
    if (tmp < minim) minim = tmp;
    paint.push_back(tmp);
  }
  int ct = 0;
  int max_ct = 0;
  for (int i = 0; i < 2 * paint.size(); i++) {
    if (paint[i % paint.size()] > minim)
      ct++;
    else {
      if (ct > max_ct) max_ct = ct;
      ct = 0;
    }
  }
  if (ct > max_ct) max_ct = ct;
  long long int ans = minim * n + max_ct;
  cout << ans;
  return 0;
}
