#include <bits/stdc++.h>
using namespace std;
vector<int> months = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int MAX = 1e5 + 55;
const int inf = 1e9 + 77;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-7;
int a[MAX];
vector<int> v;
void GenerateDivisors(int n) {
  int i;
  v.push_back(1);
  for (i = 2; i * i < n; ++i) {
    if (n % i == 0) {
      v.push_back(i);
      if (i != 2) v.push_back(n / i);
    }
  }
  if (i * i == n) v.push_back(i);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  GenerateDivisors(n);
  int mx = -inf;
  for (auto f : v) {
    if (f == n / 2 + (n & 1)) continue;
    for (int st = 0; st < f; ++st) {
      int sum = 0;
      for (int i = st; i < n; i += f) sum += a[i];
      mx = max(mx, sum);
    }
  }
  printf("%d", mx);
  return 0;
}
