#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n, t[20005], ans = -20000000;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> t[i];
  }
  for (int i = 3; i <= n; ++i) {
    if (n % i == 0) {
      int p = n / i, k = i;
      for (int j = 1; j <= p; ++j) {
        int w = j, m = 0;
        while (w <= n) {
          m += t[w];
          w += p;
        }
        if (ans < m) ans = m;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
