#include <bits/stdc++.h>
using namespace std;
int main() {
  int d[200];
  int n, m = 0, tmp = 0, i, j, p, q, k, sum = 0, max1 = -20000000;
  map<pair<int, int>, int> mymap;
  cin >> n;
  for (int i = 3; i <= (n / 2); i++) {
    if ((n % i) == 0) {
      m++;
      d[m] = i;
    }
  }
  for (i = 1; i <= n; i++) {
    cin >> j;
    sum += j;
    for (k = 1; k <= m; k++) {
      p = n / d[k];
      q = i % p;
      if (q == 0) q += p;
      mymap[pair<int, int>(q, d[k])] += j;
      if (i + p > n) {
        tmp = mymap[pair<int, int>(q, d[k])];
        if (tmp > max1) max1 = tmp;
      }
    }
  }
  if (sum > max1) max1 = sum;
  cout << max1;
  return 0;
}
