#include <bits/stdc++.h>
using namespace std;
inline void use_io_optimizations() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
int main() {
  use_io_optimizations();
  unsigned int sculptures;
  cin >> sculptures;
  vector<int> degrees(sculptures);
  for (auto& degree : degrees) {
    cin >> degree;
  }
  int max_sum{accumulate(degrees.cbegin(), degrees.cend(), 0)};
  for (unsigned int i{3}; i <= sculptures; ++i) {
    if (sculptures % i == 0) {
      for (unsigned int j{0}; j < sculptures / i; ++j) {
        int sum{0};
        for (unsigned int k{j}; k < sculptures; k += sculptures / i) {
          sum += degrees[k];
        }
        max_sum = max(max_sum, sum);
      }
    }
  }
  cout << max_sum << '\n';
  return 0;
}
