#include <bits/stdc++.h>
using namespace std;
int a[20002], b[20002];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int MAX = -2000000000;
  for (int i = 1; i <= n; i++)
    if (n % i == 0 && n / i >= 3) {
      for (int j = 0; j < i; j++) b[j] = 0;
      for (int j = 1; j <= n; j += i)
        for (int k = j; k < j + i; k++) b[(k - 1) % i] += a[k];
      for (int j = 0; j < i; j++) MAX = max(MAX, b[j]);
    }
  printf("%d", MAX);
}
