#include <bits/stdc++.h>
using namespace std;
long long a[400005];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long min1 = -1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i + n] = a[i];
    if (min1 == -1)
      min1 = a[i];
    else
      min1 = min(min1, a[i]);
  }
  int len = 0, ans = 0;
  bool flag = false;
  for (int i = 1; i <= 2 * n; i++) {
    if (a[i] > min1) {
      len++;
      ans = max(ans, len);
    } else {
      flag = false;
      len = 0;
      continue;
    }
  }
  cout << ans + min1 * n << endl;
  return 0;
}
