#include <bits/stdc++.h>
int N;
int T[20000 + 10];
int Cnt[20000 + 10];
int Ans;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &T[i]);
  Ans = -1000000000;
  for (int i = 1; i <= N; i++)
    if (N % i == 0 && N / i >= 3) {
      for (int j = 0; j < i; j++) Cnt[j] = 0;
      for (int j = 0; j < N; j++) Cnt[j % i] += T[j];
      for (int j = 0; j < i; j++)
        if (Cnt[j] > Ans) Ans = Cnt[j];
    }
  printf("%d\n", Ans);
  return 0;
}
