#include <bits/stdc++.h>
int n;
int Ar[100000];
int main() {
  int n;
  scanf("%d", &n);
  int globalsum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &Ar[i]);
    globalsum += Ar[i];
  }
  for (int div = 3; div <= n; div++) {
    if (n % div == 0) {
      for (int startIndex = 0; startIndex < n / div; startIndex++) {
        int sum = 0;
        for (int idx = startIndex; idx < n; idx += n / div) {
          sum += Ar[idx];
        }
        if (sum > globalsum) globalsum = sum;
      }
    }
  }
  printf("%d\n", globalsum);
}
