#include <bits/stdc++.h>
int t[20000];
int main() {
  int n, i, j, k, c, sum = 0, max = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", t + i);
  }
  max = -200000000;
  c = n / 3;
  for (i = 1; i <= c; i++) {
    if (n % i == 0) {
      for (j = 0; j < i; j++) {
        sum = 0;
        for (k = j; k < n; k += i) sum += t[k];
        if (sum > max) max = sum;
      }
    }
  }
  printf("%d", max);
  return 0;
}
