#include <bits/stdc++.h>
int aa[20110];
int main() {
  int n;
  int res;
  int sum;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &aa[i]);
    res = -200000000;
    for (int i = 1; i <= n / 3; i++) {
      if (n % i != 0) continue;
      if (n / i < 3) continue;
      for (int j = 1; j <= i; j++) {
        sum = 0;
        for (int k = j; k <= n; k += i) sum += aa[k];
        if (sum > res) res = sum;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
