#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, a[50000], best_sum = -12345678, curr_sum;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  if (n == 3) {
    cout << a[0] + a[1] + a[2];
    return 0;
  }
  for (i = 1; i < n / 2; i++) {
    if (n % i != 0) continue;
    for (j = 0; j < i; j++) {
      k = j;
      curr_sum = 0;
      while (k < n) {
        curr_sum += a[k];
        k += i;
      }
      if (curr_sum > best_sum) best_sum = curr_sum;
    }
  }
  cout << best_sum;
  return 0;
}
