#include <bits/stdc++.h>
using namespace std;
int n, tab[20007];
int check(int x, int start) {
  int val = 0;
  while (start < n) {
    val += tab[start];
    start += x;
  }
  return val;
}
int res;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d", &tab[i]);
  res = -1000000007;
  for (int i = 3; i <= n; i++) {
    if (n % i) continue;
    for (int j = 0; j < (n / i); j++) res = max(res, check((n / i), j));
  }
  printf("%d\n", res);
}
