#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  long long arr[n], m = INT_MAX, ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    m = min(arr[i], m);
  }
  vector<int> nom;
  for (int i = 0; i < n; ++i) {
    if (arr[i] == m) nom.push_back(i + 1);
  }
  for (int &k : nom) {
    long long t = 0;
    for (int i = k; i < n + k; ++i) {
      i %= n;
      if (arr[i] == m) break;
      ++t;
    }
    ans = max(ans, t);
  }
  cout << m * n + ans;
  return 0;
}
