#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  long long sum = 0;
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]), sum += arr[i];
  if (n < 5) {
    cout << sum;
    return 0;
  }
  for (int i = 2; i <= n / 3; i++)
    for (int k = 0; k < i && n % i == 0; k++) {
      long long temp = 0;
      for (int j = k; j < n; j += i) temp += arr[j];
      sum = max(temp, sum);
    }
  cout << sum;
  return 0;
}
