#include <bits/stdc++.h>
using namespace std;
inline void init() {
  cin.tie(0);
  cout.tie(0);
  std::ios::sync_with_stdio(false);
}
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int n, a[200005], mn = 0x3f3f3f3f3f3f3f3fll, mx = -1 * 0x3f3f3f3f3f3f3f3fll;
vector<int> v;
int main() {
  init();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    mn = min(mn, a[i]);
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == mn) v.push_back(i);
  }
  v.push_back(v[0] + n);
  long long ans = (long long)mn * (long long)n;
  for (int i = 0; i < v.size() - 1; ++i) {
    mx = max(mx, v[i + 1] - v[i] - 1);
  }
  ans += mx;
  cout << ans << "\n";
  return 0;
}
