#include <bits/stdc++.h>
using namespace std;
long long int a[20000], m = -1e18, n;
void updateMax(long long int k) {
  for (long long int i = 0; i < k; i++) {
    long long int mi = 0;
    for (long long int j = i; j < n; j += k) mi += a[j];
    m = max(m, mi);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 1; i * 3 <= n; i++)
    if (n % i == 0) updateMax(i);
  cout << m;
  return 0;
}
