#include <bits/stdc++.h>
int main() {
  int a[20001] = {0};
  int b[20001] = {0};
  int n, i, j, t;
  int ans = -100000000;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = n / 3; i >= 1; i--) {
    if (n % i) continue;
    memset(b, 0, sizeof(b));
    for (j = 1; j <= n; j++) b[j % i] += a[j];
    t = b[0];
    for (j = 1; j < i; j++)
      if (b[j] > t) t = b[j];
    if (t > ans) ans = t;
  }
  printf("%d\n", ans);
}
