#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int sz = 3e5 + 10;
;
const ll inf = 1e18;
const int lim = 1 << 8;
const ll mod = 998244353;
int n;
ll ar[sz];
ll br[sz];
int main() {
  while (scanf("%d", &n) == 1) {
    ll sum = 0, h;
    for (int i = 0; i < n; i++) {
      scanf("%lld", &ar[i]);
      sum += ar[i];
    }
    h = sum;
    int c;
    ll ans = sum;
    for (int i = 2; i < n; i++) {
      if (n % i != 0 || n / i < 3) continue;
      for (int j = 0; j < i; j++) {
        br[j] = 0;
      }
      for (int j = 0; j < n; j++) {
        br[j % i] += ar[j];
      }
      ans = max(ans, *max_element(br, br + i));
    }
    printf("%lld\n", ans);
    cerr << "---\n";
  }
  return 0;
}
