#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = ((res % p) * (x % p)) % p;
    y = y >> 1;
    x = ((x % p) * (x % p)) % p;
  }
  return res;
}
long long raichu(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = ((res) * (x));
    y = y >> 1;
    x = ((x) * (x));
  }
  return res;
}
bool isprime(long long n) {
  if (n < 2)
    return false;
  else if (n == 2)
    return true;
  else if (n % 2 == 0)
    return false;
  else {
    long long z = sqrt(n);
    for (long long i = 0; i < z - 1; i++)
      if (n % (i + 2) == 0) return false;
    return true;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    long long ans = 0;
    for (long long i = 0; i < n; i++) ans += v[i];
    vector<long long> div;
    for (long long i = 0; i < n; i++)
      if (n % (i + 1) == 0) div.push_back(i + 1);
    for (long long i = 0; i < (long long)div.size(); i++) {
      if (n / div[i] >= 3) {
        for (long long j = 0; j < div[i]; j++) {
          long long z = 0;
          long long cnt = 0;
          while ((j + z * div[i]) < n) {
            cnt += v[j + z * div[i]];
            z++;
          }
          ans = max(ans, cnt);
        }
      }
    }
    cout << ans;
  }
  return 0;
}
