#include <bits/stdc++.h>
using namespace std;
int m[20000][80] = {0};
int d[80] = {0};
int md = 0;
int a = (1 << 31);
void solve() {
  int n, t;
  scanf("%d", &n);
  for (int i = 3; i * i <= n; ++i) {
    if (!(n % i)) {
      d[md++] = i;
      if (n / i != i) d[md++] = n / i;
    }
  }
  d[md++] = 1;
  if (!(n & 1) && n / 2 > 2) {
    d[md++] = 2;
  }
  for (int i = (0), _b(n); i < _b; ++i) {
    scanf("%d", &t);
    for (int j = (0), _b(md); j < _b; ++j) {
      if (i - d[j] < 0)
        m[i][j] = t;
      else
        m[i][j] = m[i - d[j]][j] + t;
      if (i + d[j] >= n && a < m[i][j]) a = m[i][j];
    }
  }
  printf("%d\n", a);
}
int main() {
  solve();
  return 0;
}
