#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, *mas, s = 0, f = 0, max = 0;
  cin >> n;
  if (n < 6) {
    for (int i = 0; i < n; i++) {
      cin >> f;
      s += f;
    }
    cout << s;
    return 0;
  }
  mas = new int[n];
  f = 0;
  for (int i = 0; i < n; i++) {
    cin >> mas[i];
    s += mas[i];
    if (mas[i] < 0) f = 1;
  }
  if (f == 0) {
    cout << s;
    return 0;
  } else
    max = s;
  s = 0;
  f = 0;
  for (int i = 2; i < n / 2; i++) {
    if (n % i == 0 && n / i >= 3) {
      f = 1;
      for (int z = 0; z < i; z++) {
        for (int j = 0; j < n; j += i) {
          s += mas[j + z];
        }
        if (s > max) max = s;
        s = 0;
      }
    }
  }
  cout << max;
  return 0;
}
