#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> scul(n);
  for (int i = 0; i < n; ++i) cin >> scul[i];
  long long result = -1000000000;
  for (int i = 1; i < n; ++i) {
    if ((n % i == 0) && (n / i > 2)) {
      vector<long long> temp(i);
      for (int j = 0; j < n; ++j) temp[j % i] += scul[j];
      for (int j = 0; j < i; ++j) result = max(result, temp[j]);
    }
  }
  cout << result;
}
