#include <bits/stdc++.h>
int main() {
  int nSumColors, nInputColorLiter;
  int nMinFirst = 0;
  int nMinLast = 0;
  int nMinPre = 0;
  int nTempt = 0;
  int nMaxInterval = 0;
  int nMinLiter = 1000000001;
  std::cin >> nSumColors;
  for (int i = 0; i < nSumColors; i++) {
    std::cin >> nInputColorLiter;
    if (nInputColorLiter < nMinLiter) {
      nMinLiter = nInputColorLiter;
      nMinFirst = i;
      nMinLast = i;
      nMinPre = i;
    } else if (nInputColorLiter == nMinLiter) {
      nTempt = i - nMinPre - 1;
      if (nTempt > nMaxInterval) {
        nMaxInterval = nTempt;
      }
      nMinPre = i;
      nMinLast = i;
    }
  }
  if (nMaxInterval < nSumColors - (nMinLast - nMinFirst + 1)) {
    nMaxInterval = nSumColors - (nMinLast - nMinFirst + 1);
  }
  std::cout << (long long)(nSumColors) * (long long)(nMinLiter) + nMaxInterval
            << std::endl;
  return 0;
}
