#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, mx = INT_MIN, sum, poly;
  cin >> n;
  int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  vector<int> v;
  for (i = 2; i * i <= n; i++)
    if (n % i == 0) {
      v.push_back(i);
      if (i * i != n) v.push_back(n / i);
    }
  v.push_back(1);
  for (i = 0; i < v.size(); i++) {
    poly = n / v[i];
    if (poly > 2)
      for (j = 0; j < v[i]; j++) {
        sum = 0;
        for (k = j; k < n; k += v[i]) sum += a[k];
        mx = max(mx, sum);
      }
  }
  cout << mx;
  return 0;
}
