#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, mn = 1e9 + 10, idx, dist = -1;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] < mn) {
      mn = v[i];
      idx = i;
    }
  }
  int first, last;
  first = idx;
  for (int i = 0; i < n; i++) {
    if (v[i] == mn) {
      dist = max(dist, i - idx - 1);
      idx = i;
      last = i;
    }
  }
  dist = max(dist, first + n - (last + 1));
  cout << 1ll * mn * n + dist;
}
