#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool ls = false;
  if (n % 2 == 1 || n <= 5) ls = true;
  int num;
  int start;
  vector<int> vec(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> num;
    vec[i] = num;
    sum += num;
  }
  int max = sum;
  for (int j = 1; j <= n / 3; j++) {
    if (n % j == 0 && n - j >= 3) {
      for (int k = 0; k < j; k++) {
        start = k;
        sum = 0;
        for (int i = start; i < n; i += j) sum += vec[i];
        if (sum > max) max = sum;
      }
    }
  }
  cout << max;
}
