#include <bits/stdc++.h>
using namespace std;
int n, mayor = -30000000, vertices[30000], quitar[30000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &vertices[i]);
  }
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (n / i >= 3) {
        for (int j = 0; j < n; j++) {
          if (j % i == j)
            quitar[j % i] = vertices[j];
          else
            quitar[j % i] += vertices[j];
        }
        for (int j = 0; j < i; j++) {
          mayor = max(mayor, quitar[j]);
        }
      }
      if (i >= 3) {
        for (int j = 0; j < n; j++) {
          if (j % (n / i) == j)
            quitar[j % (n / i)] = vertices[j];
          else
            quitar[j % (n / i)] += vertices[j];
        }
        for (int j = 0; j < n / i; j++) {
          mayor = max(mayor, quitar[j]);
        }
      }
    }
  }
  printf("%d", mayor);
}
