#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const double EPS = 10e-9;
int a[20005];
int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    ans += a[i];
  }
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0 and n / i > 2) {
      for (int k = 0; k < i; k++) {
        int temp = 0;
        for (int j = k; j < n; j += i) temp += a[j];
        ans = max(ans, temp);
      }
      if (i >= 3) {
        for (int k = 0; k < n / i; k++) {
          int temp = 0;
          for (int j = k; j < n; j += n / i) temp += a[j];
          ans = max(ans, temp);
        }
      }
    }
  }
  cout << ans;
  return 0;
}
