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