#include <bits/stdc++.h>
using namespace std;
const int Max = 1000050;
long long vis[Max], dp[Max], a[Max];
map<string, int> mp;
pair<int, int> p[Max];
int ans, w;
bool comp(const pair<int, int> &i, const pair<int, int> &j) {
  if (i.first > j.first) return i.first > j.first;
  return abs(w - i.second) < abs(w - j.second);
}
int coun[Max];
vector<long long> idea;
int main() {
  long long mn = 10000000000, pos, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < mn) {
      mn = a[i];
      pos = i;
    }
  }
  long long last = -1, len = 0, r = -1, pos1 = pos;
  for (int i = pos + 1; i < n; i++) {
    if (a[i] != mn)
      len++;
    else {
      r = max(r, len);
      len = 0;
    }
    if (a[i] == mn) pos1 = i;
  }
  r = max(r, n - pos1 - 1 + pos);
  cout << n * mn + r;
  return 0;
}
