#include <bits/stdc++.h>
using namespace std;
long long n, sculp[40004], cumr[40004], atr;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> sculp[i];
    atr += sculp[i];
  }
  for (long long i = 1; i <= n - 1; i++)
    if (!(n % i) && (long long)(n / i) > 2)
      for (long long j = n; j >= 1; j--) {
        cumr[j] = sculp[j] + cumr[j + i];
        if (j <= i && cumr[j] > atr) atr = cumr[j];
      }
  cout << atr << endl;
}
