#include <bits/stdc++.h>
using namespace std;
const long long nmax = 200005;
const int mod = 1e9 + 7;
long long a[nmax];
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  long long mn;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (!i) mn = a[i];
    mn = min(mn, a[i]);
  }
  for (int i = 0; i < n; ++i) a[i] -= mn;
  long long ans = mn * n;
  long long cnt = 0;
  long long cur = ans;
  for (int i = 0; i < n; ++i) {
    if (a[i] > 0)
      cnt++;
    else {
      cur = max(cur, ans + cnt);
      cnt = 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] > 0)
      cnt++;
    else {
      cur = max(cur, ans + cnt);
      break;
    }
  }
  cout << cur << '\n';
  return 0;
}
