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