#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> sculptures(n);
  for (int i = 0; i < n; i++) cin >> sculptures[i];
  int ans = INT_MIN;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < i; j++)
      if (n % i == 0 && n / i >= 3) {
        int sum = 0;
        for (int k = 0; k < n / i; k++) sum += sculptures[j + k * i];
        if (sum > ans) ans = sum;
      }
  cout << ans << endl;
  return 0;
}
