#include <bits/stdc++.h>
int main() {
  unsigned n;
  std::cin >> n;
  std::vector<long long unsigned> v(n);
  for (unsigned i{0}; i < n; ++i) std::cin >> v[i];
  long long unsigned mi{*std::min_element(v.begin(), v.end())};
  std::vector<unsigned> vv{};
  for (unsigned i{0}; i < n; ++i)
    if (v[i] == mi) vv.push_back(i);
  unsigned ec{0};
  if (vv.size() == 1)
    ec = n - 1;
  else {
    for (unsigned i{0}; i < vv.size() - 1; ++i)
      if (vv[i + 1] - vv[i] - 1 > ec) ec = vv[i + 1] - vv[i] - 1;
    vv[0] += n;
    if (vv[0] - vv[vv.size() - 1] - 1 > ec) ec = vv[0] - vv[vv.size() - 1] - 1;
  }
  std::cout << n * mi + ec << '\n';
}
