#include <bits/stdc++.h>
using namespace std;
const int MAXn = 20000 + 100;
const int INF = 2e9;
int a[MAXn];
int n;
int sum(int beg, int step) {
  int ret = 0;
  for (int i = beg; i < n; i += step) ret += a[i];
  return ret;
}
int solve(int x) {
  if (n / x <= 2) return -INF;
  int mx = -INF;
  for (int i = 0; i < x; i++) mx = max(mx, sum(i, x));
  return mx;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int mx = -INF;
  for (int i = 1; i * i <= n; i++)
    if (n % i == 0) {
      mx = max(mx, solve(i));
      mx = max(mx, solve(n / i));
    }
  cout << mx << endl;
  return 0;
}
