#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long mod2 = 998244353;
const int inf = 1e9 + 10;
const long long INF = 1e18;
const long double EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> s(n);
  for (long long i = 0; i < (n); ++i) cin >> s[i];
  long long ans = 0;
  for (long long c = (1); c < (n - 1); ++c) {
    long long res = 0;
    vector<bool> used(n, false);
    for (long long k = 0; n - 1 - k * c > 0; ++k) {
      if (used[k * c]) break;
      used[k * c] = true;
      if (used[n - 1 - k * c]) break;
      used[n - 1 - k * c] = true;
      res += s[k * c] + s[n - 1 - k * c];
      chmax(ans, res);
    }
  }
  cout << ans << endl;
  return 0;
}
