#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
int n;
vector<int> a;
int mx(int m) {
  vector<int> b(m, 0);
  int i;
  for (i = 0; i < n; i++) b[i % m] += a[i];
  int ret = -INF;
  for (i = 0; i < m; i++) ret = max(ret, b[i]);
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  a.resize(n);
  int i, ans = 0;
  for (i = 0; i < n; i++) cin >> a[i], ans += a[i];
  for (int x = 2; x <= n; x++)
    if (n % x == 0 and n / x >= 3) {
      int temp = mx(x);
      ans = max(ans, temp);
    }
  cout << ans << '\n';
  return 0;
};
