#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, minx = 1e9, ind = 0;
  long long int ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] <= minx) {
      minx = a[i];
      ind = i;
    }
  }
  int lowind = -1;
  for (int i = 0; i < N; i++)
    if (a[i] == minx) {
      lowind = i;
      break;
    }
  ans = 1LL * minx * N;
  long long int mx = 0, cur = 0;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < N; j++) {
      if (a[j] == minx) {
        mx = max(mx, cur);
        cur = 0;
      } else
        cur++;
    }
  cout << ans + mx << endl;
  return 0;
}
