#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> vec(n);
  int sum1 = 0;
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    sum1 += vec[i];
  }
  int max1 = sum1;
  int n1 = n / 3;
  for (int i = 2; i <= n1; i++) {
    sum1 = 0;
    if (n % i == 0) {
      for (int z = 0; z < i; z++) {
        sum1 = 0;
        for (int j = 0 + z; j < n; j = j + i) {
          if (j > n)
            sum1 += vec[z];
          else
            sum1 += vec[j];
        }
        max1 = max(max1, sum1);
      }
    }
  }
  cout << max1;
  return 0;
}
