#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, a[20010], ans = -1 * (1e18), k = 1;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  while (3 <= n / k) {
    if (!(n % k))
      for (int i = 0; i < k; i++) {
        long long sum = 0, cnt = 0;
        for (int j = i; j < n; j += k) {
          sum += a[j];
          cnt++;
        }
        ans = ans > sum ? ans : sum;
      }
    k++;
  }
  cout << ans;
  return 0;
}
