#include <bits/stdc++.h>
using namespace std;
long long s[400005];
int main(int argc, char** argv) {
  long long n;
  long long su = 0;
  long long inf = 0x3f3f3f3f;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    su += s[i];
    s[i + n] = s[i];
    inf = min(inf, s[i]);
  }
  long long t = 0;
  long long ans = 0;
  for (int i = 1; i <= (n * 2); i++) {
    if (s[i] == inf) {
      ans = max(t, ans);
      t = 0;
    } else {
      t++;
    }
  }
  cout << n * inf + ans << endl;
  return 0;
}
