#include <bits/stdc++.h>
#pragma gcc optimize(O3)
using namespace std;
using namespace std;
const long long INF = (long long)(1e18);
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const double eps = 1e-12;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long pows(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2 == 1) return (a * pows(a, b - 1));
  if (b % 2 == 0) {
    long long c = pows(a, b / 2);
    return (c * c);
  }
}
struct dir {
  string name;
  int p;
  map<string, int> g;
  dir(string name, int p) : name(name), p(p) {}
};
vector<dir> op;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int best = -inf;
  for (int i = 3; i <= n; i++) {
    if (n % i != 0) continue;
    int u = n / i;
    vector<int> k(u);
    for (int j = 0; j < n; j++) {
      k[j % u] += a[j];
    }
    for (int j = 0; j < u; j++) best = max(best, k[j]);
  }
  cout << best;
}
