#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 12], mx = INT_MIN;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n / 3; i++) {
    if (n % i == 0) {
      for (int j = 0; j < i; j++) {
        int t = 0;
        for (int k = j; k < n; k += i) {
          t += a[k];
        }
        mx = max(mx, t);
      }
    }
  }
  cout << mx << endl;
}
