#include <bits/stdc++.h>
using namespace std;
vector<int> dijel(int n) {
  vector<int> ret(1, 1);
  for (int i = 2; i < n / 2; ++i) {
    if (n % i == 0) ret.push_back(i);
  }
  return ret;
}
int main(void) {
  int n;
  int sol = -1000 * 20000;
  int val[20001];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &val[i]);
  }
  vector<int> d = dijel(n);
  for (int i = 0; i < (int)d.size(); ++i) {
    for (int j = 0; j < d[i]; ++j) {
      int tmp = 0;
      for (int k = 0; k < n / d[i]; ++k) {
        tmp += val[k * d[i] + j];
      }
      sol = (sol < tmp) ? tmp : sol;
    }
  }
  printf("%d\n", sol);
  return 0;
}
