#include <bits/stdc++.h>
using namespace std;
int GCD(int x, int y) {
  int z;
  if (x < y) swap(x, y);
  while (1) {
    z = x % y;
    if (z == 0) return y;
    x = y;
    y = z;
  }
}
long long Divisors(long long n) {
  long long result = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (sqrt(n) == i)
      result++;
    else if (n % i == 0)
      result += 2;
  }
  return result;
}
int main() {
  unsigned long long n, res, N[200000], Min, indexofminlast = 0, flag = 0, M, x,
                                             y = 1, z, o;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> N[i];
  }
  Min = N[0];
  for (int i = 1; i < n; i++) {
    if (Min >= N[i]) {
      Min = N[i];
      indexofminlast = i;
    }
  }
  x = indexofminlast;
  for (int i = 0; i <= indexofminlast; i++) {
    if (N[i] == Min) {
      if (x == indexofminlast) {
        y = n + i - x - 1;
        x = i;
        z = i;
      } else {
        flag = 1;
        x = i;
        o = x - z - 1;
        if (o > y) y = o;
        z = i;
      }
    }
  }
  if (y == 0)
    res = Min * n;
  else if (flag == 1)
    res = Min * n + y;
  else
    res = Min * n + n - 1;
  cout << res;
}
