#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e4 + 111;
int t[MAXN];
int main() {
  int ans = 0;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
    ans += t[i];
  }
  for (int i = 2; i <= n / 3; ++i) {
    if (n % i == 0) {
      for (int k = 1; k <= i; ++k) {
        int tem = 0;
        for (int j = k; j <= n; j += i) tem += t[j];
        if (tem > ans) ans = tem;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
