#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  long long n;
  cin >> n;
  ;
  vector<long long> data(n);
  for (long long i = 0; i < n; i++) {
    cin >> data[i];
  }
  long long ans = 0, p = 1;
  vector<long long> used(n, 0);
  for (long long i = 1; i < n; i++) {
    long long tmp = 0;
    long long l = 0 + i, r = n - 1 - i;
    while (l < data.size() - 1 && r > 0 && l != r && used[l] != p &&
           used[r] != p) {
      tmp += data[l] + data[r];
      used[l] = used[r] = p;
      l += i;
      r -= i;
      ans = max(ans, tmp);
    }
    p++;
  }
  std::cout << ans << std::endl;
  return 0;
}
