#include <bits/stdc++.h>
using namespace std;
long long n, m, w, r, k, i, j, s, q, x, y, l, a[22000];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i], s += a[i];
    if (a[i] < 0) k = 1;
  }
  if (k == 0) {
    cout << s;
    return 0;
  }
  for (l = 2; l <= n; l++)
    if (n % l == 0 && n / l >= 3)
      for (j = 1; j <= l; j++) {
        m = 0;
        for (i = j; i <= n; i += l) m += a[i];
        s = max(s, m);
      }
  cout << s;
}
