#include <bits/stdc++.h>
using namespace std;
int n, g(0), sc, sm(0);
vector<int> t, d, e;
int main() {
  scanf("%d", &n);
  t.resize(n);
  for (int i = 0; i < n; i++) scanf("%d", &t[i]);
  for (int i = 2; i <= n / 3; i++)
    if (n % i == 0) {
      d.push_back(n / i);
      e.push_back(i);
      g++;
    }
  for (int i = 0; i < n; i++) sm += t[i];
  for (int i = 0; i < g; i++)
    for (int j = 0; j < e[i]; j++) {
      sc = 0;
      for (int k = j; k < n; k += e[i]) sc += t[k];
      sm = max(sc, sm);
    }
  printf("%d", sm);
  return 0;
}
