#include <bits/stdc++.h>
using namespace std;
int n;
int a[212345];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  int lemin = 1e9 + 5;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    lemin = min(lemin, a[i]);
  }
  int curstreak = 0;
  int maxstreak = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (a[i % n] > lemin) {
      curstreak++;
      maxstreak = max(maxstreak, curstreak);
    } else {
      curstreak = 0;
    }
  }
  long long res = (long long)lemin * n + maxstreak;
  cout << res;
  return 0;
}
