#include <bits/stdc++.h>
using namespace std;
int f[20005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> f[i];
  int max_sum = -1000 * 20001;
  for (int i = 1; 3 * i <= n; i++)
    if (n % i == 0)
      for (int j = 0; j < i; j++) {
        int cur_sum = 0;
        for (int k = j; k < n; k += i) cur_sum += f[k];
        if (max_sum < cur_sum) max_sum = cur_sum;
      }
  cout << max_sum << endl;
}
