#include <bits/stdc++.h>
using namespace std;
long long num[2000000];
int main() {
  int n;
  cin >> n;
  long long minn = 1000000000000000000;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    if (num[i] < minn) minn = num[i];
  }
  long long maxn = 0;
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    if (num[i] > minn)
      cnt++;
    else {
      if (cnt > maxn) maxn = cnt;
      cnt = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (num[i] > minn)
      cnt++;
    else {
      if (cnt > maxn) maxn = cnt;
      break;
    }
  }
  cout << minn * n + maxn << endl;
  return 0;
}
