#include <bits/stdc++.h>
using namespace std;
const int maxn = 20001;
const int inf = (1 << 30);
int n;
int t[maxn];
int ans = -inf;
void calc(int d) {
  if (n / d < 3) return;
  int sum = 0;
  for (int start = 0; start < d; start++) {
    sum = 0;
    for (int i = start; i < n; i += d) sum += t[i];
    ans = max(ans, sum);
  }
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &t[i]);
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      calc(i);
      calc(n / i);
    }
  }
  cout << ans << endl;
  return 0;
}
