#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 123;
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
const double eps = 1e-6;
inline void boost() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
long long n, a[200111], mini = INF, ans;
pair<long long, long long> p[200111], s[200111];
int main() {
  boost();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mini = min(mini, a[i]);
  }
  for (int i = 1; i <= n; i++) {
    p[i] = make_pair(a[i], i);
    if (i > 1 && p[i - 1].first <= p[i].first) p[i] = p[i - 1];
  }
  for (int i = n; i >= 1; i--) {
    s[i] = make_pair(a[i], i);
    if (i < n && s[i + 1].first < s[i].first) s[i] = s[i + 1];
  }
  for (int i = 1; i <= n; i++) {
    if (s[i].first == mini) {
      ans = max(ans, (mini * n) + (s[i].second - i));
    } else {
      ans = max(ans, (mini * n) + n - i + p[i].second);
    }
  }
  cout << ans;
  return 0;
}
