#include <bits/stdc++.h>
using namespace std;
int arr[20000 + 1];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)n; i++) cin >> arr[i];
  int ret = -999999999, slice;
  for (int amount = (int)3; amount <= (int)n; amount++) {
    if (n % amount) continue;
    slice = n / amount;
    int sum;
    for (int j = 0; j < (int)slice; j++) {
      sum = 0;
      for (int k = 0; k < (int)amount; k++) sum += arr[j + k * slice];
      ret = max(ret, sum);
    }
  }
  cout << ret << "\n";
  return 0;
}
