#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  unsigned int N;
  cin >> N;
  int val[N], ma = 0;
  for (unsigned int i = 0; i < N; i++) {
    cin >> val[i];
    ma += val[i];
  }
  for (unsigned int i = 2; i < N / 2; i++)
    if (N % i == 0 && N / i > 2)
      for (unsigned int j = 0; j < i; j++) {
        int temp = 0;
        for (unsigned int k = 0; k < N / i; k++) temp += val[(k * i + j) % N];
        ma = max(ma, temp);
      }
  cout << ma;
  return 0;
}
