#include <bits/stdc++.h>
using namespace std;
int64_t seg_a[100000] = {};
int64_t seg_b[100000] = {};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> ss(n);
  for (auto& s : ss) {
    cin >> s;
  }
  int64_t ans = 0;
  for (int b = 1; b <= (n / 2); b++) {
    if (n - 1 % b == 0) continue;
    int c = (n - 1) % b;
    int l = 0;
    {
      int64_t sum_a = 0;
      int64_t sum_b = 0;
      for (int i = 0; true; i++) {
        if (n <= i * b) break;
        sum_b += ss[i * b];
        seg_b[i + 1] = sum_b;
        if (n <= i * b + c) break;
        sum_a += ss[i * b + c];
        seg_a[i + 1] = sum_a;
        l++;
      }
    }
    for (int d = 0; d <= l; d++) {
      if (c == 0) {
        if (d <= (l / 2)) continue;
      }
      int64_t val = (seg_a[l] - seg_a[d]) + seg_b[l - d];
      ans = max(ans, val);
    }
  }
  cout << ans << endl;
  return 0;
}
