#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T a) {
  return a * a;
}
int n;
int a[21000];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int best = -1000000000;
  for (int i = 3; i <= n; i++)
    if (n % i == 0) {
      int g = n / i;
      for (int j = 0; j < g; j++) {
        int cur = 0;
        for (int k = j; k < n; k += g) cur += a[k];
        best = max(cur, best);
      }
    }
  cout << best;
  return 0;
}
