#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16, mod = 1e9 + 7;
long long arr[400004];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long mi = inf;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    mi = min(mi, arr[i]);
    arr[n + i] = arr[i];
  }
  long long ans = mi * n;
  for (int i = 1; i <= 2 * n; i++) arr[i] -= mi;
  long long cnt = 0;
  long long ma = -inf;
  for (int i = 1; i <= 2 * n; i++) {
    if (arr[i] != 0)
      cnt++;
    else {
      ma = max(ma, cnt);
      cnt = 0;
    }
  }
  cout << ans + ma;
  return 0;
}
