#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> uses;
int vet[20000];
void precalc() {
  for (int i = 1; (long long)i * i <= n; ++i) {
    if (n % i) continue;
    int j = n / i;
    uses.push_back(i);
    if (i != j) uses.push_back(j);
  }
}
void solve() {
  int best = INT_MAX + 1;
  for (int i = 0; i < uses.size(); ++i) {
    int d = uses[i], z = n / d;
    if (n / d < 3) continue;
    for (int j = 0; j < d; ++j) {
      int res = 0;
      for (int k = 0; k < z; ++k) res += vet[j + k * d];
      best = max(best, res);
    }
  }
  printf("%d\n", best);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &vet[i]);
  precalc();
  solve();
  return 0;
}
