#include <bits/stdc++.h>
using namespace std;
vector<long long int> divisors(long long int n) {
  vector<long long int> a, b;
  for (int i = 1; i <= (n + i - 1) / i; ++i) {
    if (n % i == 0) {
      a.push_back(i);
      b.push_back(n / i);
    }
  }
  if (b.back() == a.back()) b.pop_back();
  reverse(b.begin(), b.end());
  a.insert(a.end(), b.begin(), b.end());
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  long long int N;
  cin >> N;
  vector<long long int> a(N);
  for (long long int i = 0; i < (long long int)(N); ++i) cin >> a[i];
  vector<long long int> ds = divisors(N);
  long long int mx = -(1ll << 62);
  for (long long int d : ds) {
    for (int s = 0; s < d; ++s) {
      long long int sum = 0;
      long long int c = 0;
      for (int j = s; j < N; j += d) {
        sum += a[j];
        c++;
      }
      if (c >= 3) {
        mx = max(mx, sum);
      }
    }
  }
  cout << mx << endl;
  return 0;
}
