#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a[20002], sum, i, j, k, n, ans = -1e14;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 3; i <= n; i++) {
    if (n % i == 0) {
      for (j = 1; j * i <= n; j++) {
        sum = 0;
        for (k = j; k <= n; k += (n / i)) sum += a[k];
        ans = max(ans, sum);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
