#include <bits/stdc++.h>
using namespace std;
inline int mini(int a, int b) { return a < b ? a : b; }
inline int maxi(int a, int b) { return a > b ? a : b; }
int main() {
  int n;
  scanf("%d", &n);
  int *a = new int[n];
  int najm = 1000000010;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    najm = mini(najm, a[i]);
  }
  vector<int> vec;
  for (int i = 0; i < n; i++) {
    if (a[i] == najm) {
      vec.push_back(i);
    }
  }
  int najv = 0;
  for (int i = 0; i < vec.size() - 1; i++) {
    najv = maxi(najv, vec[i + 1] - vec[i] - 1);
  }
  najv = maxi(najv, n - 1 - vec[vec.size() - 1] + vec[0]);
  long long res = ((long long)najm) * (long long)n + (long long)najv;
  cout << res;
  return 0;
}
