#include <bits/stdc++.h>
using namespace std;
int v[20000];
int main() {
  ios::sync_with_stdio(false);
  long long best = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> v[i], best += v[i];
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      if (n / i >= 3)
        for (int j = 0; j < i; j++) {
          long long sum = 0;
          for (int k = j; k < n; k += i) sum += v[k];
          best = max(best, sum);
        }
      int q = n / i;
      if (n / q >= 3)
        for (int j = 0; j < q; j++) {
          long long sum = 0;
          for (int k = j; k < n; k += q) sum += v[k];
          best = max(best, sum);
        }
    }
  cout << best << endl;
}
