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