#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, arr[100005], dp[100005];
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  dp[0] = arr[0];
  long long q = sqrt(n), supermax = -10000000000000ll;
  for (int i = 1; i <= q; ++i) {
    if (n % i == 0) {
      for (int j = 1; j < n; ++j) {
        if (j - i >= 0)
          dp[j] = arr[j] + dp[j - i];
        else
          dp[j] = arr[j];
        if (j >= n - i && (n / i >= 3)) supermax = max(supermax, dp[j]);
      }
      for (int j = 1; j < n; ++j) {
        if (j - n / i >= 0)
          dp[j] = arr[j] + dp[j - n / i];
        else
          dp[j] = arr[j];
        if (j >= n - n / i && (i >= 3)) supermax = max(supermax, dp[j]);
      }
    }
  }
  cout << supermax << "\n";
  return 0;
}
