#include <bits/stdc++.h>
using namespace std;
unsigned long long n, minval = INT_MAX;
unsigned long long a[200001];
int main(void) {
  cin >> n;
  for (unsigned i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] < minval) minval = a[i];
  }
  unsigned long long longest_over = 0, cur = 0;
  for (unsigned i = 0; i < n; ++i) {
    if (a[i] > minval) {
      ++cur;
      if (cur > longest_over) longest_over = cur;
    } else {
      cur = 0;
    }
  }
  for (unsigned i = 0; i < n; ++i) {
    if (a[i] <= minval)
      break;
    else {
      ++cur;
      if (cur > longest_over) longest_over = cur;
    }
  }
  cout << n * minval + longest_over << endl;
  return 0;
}
