#include <bits/stdc++.h>
using namespace std;
int n, t[20010];
int main() {
  while (~scanf("%d", &n)) {
    int ans = -1000000000;
    for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
    for (int i = 1; i <= n; i++)
      if (n % i == 0 && n / i >= 3) {
        for (int s = 1; s <= i; s++) {
          int temp = 0;
          for (int j = 0; i * j + s <= n; j++) temp += t[i * j + s];
          ans = max(ans, temp);
        }
      }
    printf("%d\n", ans);
  }
  return 0;
}
