#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int n, m;
int main() {
  scanf("%d", &n);
  a.resize(n);
  bool b = true;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < 0) b = false;
    sum += a[i];
  }
  if (b) {
    cout << sum;
    return 0;
  }
  for (int i = 2; i < n; i++) {
    if (n % i != 0) continue;
    int k = (n - 1) / i;
    if (k < 2) break;
    for (int l = 0; l + k * i < n; l++) {
      int s = 0;
      for (int j = l; j < n; j += i) s += a[j];
      sum = max(sum, s);
    }
  }
  cout << sum;
  return 0;
}
