#include <bits/stdc++.h>
using namespace std;
int a[100000], i, j, k, l, m, n;
long long maxi, o;
int main() {
  maxi = -1000000000000;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n / 3; i++) {
    if (n % i == 0) {
      for (k = 1; k <= i; k++) {
        o = 0;
        for (j = k; j <= n; j = j + i) o += a[j];
        if (o > maxi) maxi = o;
      }
    }
  }
  cout << maxi << endl;
  return 0;
}
