#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "}";
}
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& v) {
  os << "{";
  os << v.first << ", " << v.second;
  return os << "}";
}
using point = complex<double>;
using ll = int64_t;
int my_main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> s(n);
  for (ll& i : s) cin >> i;
  ll ret = 0;
  vector<ll> dp(n);
  for (ll c = 1; c <= n - 1; c++) {
    dp[0] = 0;
    vector<bool> used(n, false);
    for (ll k = 1; (n - 1) - (k * c) > 0L; k++) {
      ll a0 = (n - 1) - k * c;
      ll a1 = k * c;
      if (used[a0]) break;
      used[a0] = true;
      if (used[a1]) break;
      used[a1] = true;
      dp[k] = dp[k - 1] + s[a0] + s[a1];
      ret = max(ret, dp[k]);
    }
  }
  cout << ret << endl;
  return 0;
}
int main(int argc, char** argv) { return my_main(argc, argv); }
