#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) arr.push_back(arr[i]);
  auto it = min_element(arr.begin(), arr.end());
  int m = *it;
  int l = 0;
  int prev = n + 1;
  for (int i = 0; i < 2 * n; i++) {
    if (arr[i] == m) {
      if (i - prev > l) {
        l = i - prev;
      }
      prev = i;
    }
  }
  cout << (1ll * n * m + l - 1);
}
