#include <bits/stdc++.h>
using namespace std;
int head[20005];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &head[i]);
    }
    int sum = -200000000;
    int ans;
    for (int i = 3; i <= n; i++) {
      int num = n / i;
      if (n % i == 0) {
        for (int j = 1; j <= num; j++) {
          ans = 0;
          for (int k = j; k <= n; k += num) {
            ans += head[k];
          }
          if (sum < ans) {
            sum = ans;
          }
        }
      }
    }
    if (n <= 5) {
      sum = 0;
      for (int i = 1; i <= n; i++) {
        sum += head[i];
      }
    }
    printf("%d\n", sum);
  }
}
