#include <bits/stdc++.h>
using namespace std;
int n, t[20000];
int main() {
  cin >> n;
  int i, j, k = 1, sum, max_sum = INT_MIN;
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
  }
  while (1) {
    if (n / k < 3) {
      break;
    }
    if (n % k == 0) {
      for (int i = 0; i < k; ++i) {
        sum = 0;
        j = i;
        do {
          sum += t[j];
          j = (j + k) % n;
        } while (j != i);
        if (sum > max_sum) {
          max_sum = sum;
        }
      }
    }
    ++k;
  }
  cout << max_sum;
  return 0;
}
