#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, i;
  unsigned long long min = 0x7fffffff;
  cin >> n;
  vector<unsigned long long> a(n, 0);
  for (i = 0; i <= n - 1; i++) {
    cin >> a[i];
    if (a[i] < min) min = a[i];
  }
  unsigned long long ans = n * min;
  unsigned long long count = 0;
  unsigned long long countmax = count;
  for (i = 0; i <= n - 1; i++) a[i] -= min;
  for (i = 0; i <= 2 * n; i++) {
    if (a[i % n] == 0)
      count = 0;
    else {
      count++;
      if (count > countmax) countmax = count;
    }
  }
  cout << (ans + countmax) << "\n";
  return 0;
}
