#include <bits/stdc++.h>
using namespace std;
int n, a[20004], b[20004];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d", &a[i]);
  int ans = -2100000000;
  for (int k = 3; k <= n; k++)
    if (!(n % k)) {
      int l = n / k;
      for (int i = 0; i < (n); i++) b[i] = a[i] + (i >= l ? b[i - l] : 0);
      for (int i = 0; i < (l); i++) ans = max(ans, b[n - 1 - i]);
    }
  printf("%d\n", ans);
  return 0;
}
