#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int tmp;
  vector<int> t;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    t.push_back(tmp);
  }
  int max(-2000000);
  for (int k = 1; k <= n / 3; k++) {
    if (n % k == 0) {
      for (int b = 0; b < k; b++) {
        int S = 0;
        int cnt = 1;
        for (int i = b; cnt <= n / k; i += k) {
          S += t[i];
          cnt++;
        }
        if (S > max) max = S;
      }
    }
  }
  cout << max << endl;
  return 0;
}
