#include <bits/stdc++.h>
using namespace std;
long long int n, d, mini, first, firstest, ans, dist;
vector<long long int> num;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin >> n;
  mini = 1000000005;
  bool done = false;
  for (__typeof(n) i = 0; i < n; i++) {
    cin >> d;
    num.push_back(d);
    mini = min(mini, d);
  }
  for (__typeof(n) i = 0; i < n; i++) {
    if (num[i] == mini) {
      first = i;
      firstest = i;
      break;
    }
  }
  for (__typeof(first + 1) i = first + 1; i < n; i++) {
    if (num[i] == mini) {
      dist = max(dist, i - first);
      first = i;
    }
  }
  ans = n * mini;
  if (first == firstest) {
    ans = ans + n - 1;
  } else {
    dist = max(dist - 1, n - first - 1 + firstest);
    ans = ans + dist;
  }
  cout << ans;
  return 0;
}
