#include <bits/stdc++.h>
using namespace std;
int n;
int prime[] = {2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,
               41,  43,  47,  53,  59,  61,  67,  71,  72,  79,  83,  89,
               97,  101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
               157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211};
map<int, int> mp;
vector<int> x;
void divisor() {
  int i, lim = sqrt(n) + 1, cnt, m = n;
  for (i = 0; i < 43 && prime[i] < lim; i++) {
    if (m % prime[i] == 0) {
      cnt = 0;
      x.push_back(prime[i]);
      while (m % prime[i] == 0) {
        m /= prime[i];
        cnt++;
      }
      mp[prime[i]] = cnt;
      lim = sqrt(m) + 1;
    }
  }
  if (m > 1) {
    mp[m] = 1;
    x.push_back(m);
  }
}
vector<int> v;
void rec(int cur, int num) {
  int i, lim;
  if (cur == mp.size()) {
    if (num < (n / 2)) v.push_back(num);
    return;
  }
  lim = 1;
  for (i = 0; i <= mp[x[cur]]; i++) {
    rec(cur + 1, num * lim);
    lim *= x[cur];
  }
}
int main() {
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  divisor();
  int sum = 0;
  for (int i = 0; i < n; i++) sum += arr[i];
  int mx = sum;
  rec(0, 1);
  for (int i = 2; i < (n / 2); i++) {
    if (n % i == 0) {
      for (int j = 0; j < i; j++) {
        sum = 0;
        for (int k = j; k < (n); k += i) {
          sum += arr[k];
        }
        mx = max(sum, mx);
      }
    }
  }
  cout << mx << endl;
  return 0;
}
