#include <bits/stdc++.h>
int n;
int mas[20005];
int main() {
  scanf("%d", &n);
  long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &mas[i]);
    sum += mas[i];
  }
  long max = sum;
  for (int i = 2; i < n / 2; i++) {
    if (n % i == 0) {
      for (int o = 0; o < i; o++) {
        sum = 0;
        for (int p = o; p < n; p += i) sum += mas[p];
        if (sum > max) max = sum;
      }
    }
  }
  printf("%ld", max);
  return 0;
}
