#include <bits/stdc++.h>
using namespace std;
int N, T[20010], result = -20000000;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> T[i];
  for (int i = 1; i <= N / 3; i++)
    if (N % i == 0)
      for (int j = 0; j < i; j++) {
        int sum = 0;
        for (int k = j; k < N; k += i) sum += T[k];
        result = max(result, sum);
      }
  cout << result << endl;
  return 0;
}
