#include <bits/stdc++.h>
using namespace std;
int inline ABS(int a) {
  if (a > 0)
    return a;
  else
    return -a;
}
int t[20100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t[i]);
  }
  if (n == 3) {
    printf("%d\n", t[0] + t[1] + t[2]);
    return 0;
  } else if (n == 4) {
    printf("%d\n", t[0] + t[1] + t[2] + t[3]);
    return 0;
  }
  int mx = -1000000000;
  for (int i = 1; i <= n / 3; i++) {
    if (n % i == 0) {
      for (int j = 0; j < i; j++) {
        int sum = 0;
        for (int k = j; k < n; k += i) {
          sum += t[k];
        }
        mx = max(mx, sum);
      }
    }
  }
  cout << mx << "\n";
  return 0;
}
