#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[20001];
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int max = INT_MIN;
  int val;
  for (int i = 1; i <= n / 3; i++) {
    if (n % i) continue;
    for (int j = 1; j <= i; j++) {
      val = 0;
      for (int k = j; k <= n; k += i) {
        val += a[k];
      }
      if (val > max) max = val;
    }
  }
  cout << max << endl;
  return 0;
}
