#include <bits/stdc++.h>
using namespace std;
const int N = 20000005;
int n, k, x, t, a, b;
string s;
vector<int> v;
int main() {
  cin >> n;
  int mn = 2e9;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
    mn = min(x, mn);
  }
  vector<int> mnLs;
  for (int i = 0; i < n; i++) {
    if (v[i] == mn) {
      mnLs.push_back(i);
    }
  }
  long long mx = 0;
  if (mnLs.size() == 1) {
    mx = (n - 1) * (mn + 1) + 1;
  }
  for (int i = 1; i < mnLs.size(); i++) {
    long long cnt = (mnLs[i] - mnLs[i - 1] - 1) + (1ll * n * mn);
    mx = max(cnt, mx);
  }
  mx = max(mx, (1ll * n - 1 - mnLs.back() + mnLs[0]) + (1ll * n * mn));
  cout << mx;
  return 0;
}
