#include <bits/stdc++.h>
using namespace std;
const int maxint = -1u >> 1;
vector<int> a;
int t[20010];
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &t[i]);
    ans += t[i];
  }
  for (int i = 2; i <= n / 3; i++)
    if (n % i == 0) a.push_back(i);
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < a[i]; j++) {
      int tmp = 0;
      int f = 0;
      for (int k = j; k < n; k += a[i]) {
        f++;
        tmp += t[k];
      }
      if (f < 3) continue;
      ans = max(tmp, ans);
    }
  }
  cout << ans << endl;
  return 0;
}
