#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const double finf = 1.0e18;
const double eps = 1.0e-8;
int n, t[20005], ans;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &t[i]);
  ans = -inf;
  for (int i = 3; i <= n; i++) {
    if (n % i == 0) {
      int I = n / i;
      for (int j = 0; j < I; j++) {
        int tmp = 0;
        for (int k = j; k < n; k += I) tmp += t[k];
        ans = max(ans, tmp);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
