#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> v;
  long long mn = 10000000000, x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x < mn) {
      mn = x;
    }
    v.push_back(x);
  }
  long long ans = (mn * n), cnt = 0, mx = 0;
  int nn = n + n;
  for (int i = 0; i < n; i++) {
    v[i] -= mn;
  }
  for (int i = 0; i < nn; i++) {
    x = i % n;
    if (v[x])
      cnt++;
    else
      cnt = 0;
    mx = max(cnt, mx);
  }
  cout << ans + mx << endl;
}
