#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *t = new int[n];
  int max = 0;
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
    max += t[i];
  }
  int tmp = 0;
  int i, j, k;
  for (i = 1; i <= n / 3; ++i) {
    if (n % i == 0) {
      for (j = 0; j < i; ++j) {
        for (k = j; k < n; k += i) {
          tmp += t[k];
        }
        if (tmp > max) max = tmp;
        tmp = 0;
      }
    }
  }
  cout << max << endl;
  return 0;
}
