#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int N, A[20010], S = INT_MIN, P, R;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 3; i <= N; i++)
    if (!(N % i)) {
      P = N / i;
      for (int k = 0; k < P; k++) {
        R = 0;
        for (int j = k; j < N; j += P) R += A[j];
        S = max(S, R);
      }
    }
  cout << S << endl;
  return 0;
}
