#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[20024];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = -29999999;
  for (int i = 0; i < n / 3; i++) {
    if (n % (i + 1) == 0) {
      for (int j = 0; j <= i; j++) {
        int sum = 0;
        for (int k = j; k < n; k += i + 1) sum += a[k];
        if (sum > ans) ans = sum;
      }
    }
  }
  cout << ans << endl;
}
