#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[20002];
  int n, value = -100000000, j, sum;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i * 3 <= n; i++) {
    if ((n % i) == 0) {
      for (int k = 0; k < i; k++) {
        for (j = k, sum = 0; j < n; j += i) sum += a[j];
        value = max(value, sum);
      }
    }
  }
  cout << value << "\n";
}
