#include <bits/stdc++.h>
template <typename T>
std::istream& operator>>(std::istream& input, std::vector<T>& v) {
  for (T& a : v) input >> a;
  return input;
}
using integer = unsigned long long;
void answer(integer v) { std::cout << v << '\n'; }
void solve(const std::vector<unsigned>& a) {
  const size_t n = a.size();
  size_t l = 0, r = 0, d = 0;
  for (size_t i = 0; i < n; ++i) {
    if (a[i] < a[l]) {
      l = i;
      r = i;
      d = 0;
    }
    if (a[i] == a[l]) {
      d = std::max<int>(d, i - r - 1);
      r = i;
    }
  }
  d = std::max<int>(d, l + n - r - 1);
  answer(1ull * n * a[l] + d);
}
int main() {
  size_t n;
  std::cin >> n;
  std::vector<unsigned> a(n);
  std::cin >> a;
  solve(a);
  return 0;
}
