#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, i, sum = 0, a[20000];
  cin >> n;
  long max = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    max += a[i];
  }
  int k, l, now;
  for (i = 2; n / i >= 3; i++)
    if (n % i == 0)
      for (l = 0; l < i; l++) {
        for (k = l, now = 0; k < n; k += i) now += a[k];
        if (max < now) max = now;
      }
  cout << max;
  return 0;
}
