#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
long long n;
bool check(long long k) { vector<long long> tmp(n, 0); }
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  vector<long long> a(n + 1);
  for (long long i = (0); i < ((n)); i++) cin >> a[i];
  vector<long long> sum(n + 1);
  for (long long i = (1); i < (n + 1); i++) {
    for (long long j = (1); j < (n); j++) {
      if (n - 1 - i * j < 0) break;
      sum[i] += a[n - 1 - i * j];
    }
  }
  long long ans = 0;
  for (long long i = (1); i < (n); i++) {
    if ((n - 1) % i != 0) continue;
    ans = max(sum[i], ans);
  }
  cout << ans << endl;
  return 0;
}
