#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n - 1; i++) cin >> a.at(i);
  vector<vector<int>> data;
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      if (i == j)
        data.at(i).at(j) = 0;
      else {
        int distance;
        if (i < j)
          distance = j - i;
        else
          distance = i - j;
        data.at(i).at(j) = a.at(i) * distance;
      }
    }
  }
  vector<long long> res(n);
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      int num = i + j;
      if (num < n) num = n - i + j;
      res.at(i) += data.at(num).at(num);
    }
  }
  sort(res.begin(), res.end(), greater<int>());
  cout << res[0] << endl;
  return 0;
}
