#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int v[n + 1];
  long long int Rmin = 1e9 + 1;
  int Rindex = -1;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] <= Rmin) {
      Rmin = v[i];
      Rindex = i;
    }
  }
  long long int complete_cycle = Rmin * n;
  int diff = 0;
  int global = 0;
  for (int j = 0; j < n + n; j++) {
    int i = j % n;
    if (v[i] == Rmin)
      diff = 0;
    else
      diff++;
    if (diff > global) {
      global = diff;
    }
  }
  long long int total = complete_cycle + global;
  cout << total << endl;
}
