#include <bits/stdc++.h>
using namespace std;
int n, _;
int v[200007];
void go() {
  cin >> n;
  int mn = 1e9;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    mn = min(mn, v[i]);
  }
  unsigned long long count = 0;
  int curr = 0, mx = 0;
  count = 1ULL * mn * n;
  for (int i = 0; i < 2; i++) {
    for (int j = 1; j <= n; j++) {
      if (v[j] == mn) {
        mx = max(mx, curr);
        curr = 0;
      } else
        curr++;
    }
  }
  cout << count + mx << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  go();
  return 0;
}
