#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  int a[n];
  long long sum(0), lsum(0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 1; i < n; i++) {
    if (n / i < 3) break;
    if (n % i != 0) continue;
    for (int j = 1; j <= i; j++) {
      lsum = 0;
      for (int k = j - 1; k < n; k += i) lsum += a[k];
      sum = max(sum, lsum);
    }
  }
  cout << sum;
  return 0;
}
