1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
#define rep(i, p, k) for (int i = (p); i < (k); ++i)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define fi first
#define sc second
#ifndef DEBUG
#define debug(...)
#else
#include "debug.h"
#endif
using namespace std;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> t(n);
  for (auto &v : t)
    cin >> v;
  long long s = accumulate(all(t), 0LL);
  vector<int> d;
  rep(i, 1, n + 1) if (s % i == 0) d.push_back(i);
  t.push_back(0);
  for (int i = n; i >= 1; i--)
    t[i] -= t[i - 1];
  auto check = [&](int x) {
    rep(i, 0, x) {
      long long sum = 0;
      for (int j = i; j <= n; j += x) {
        sum += t[j];
        if (sum < 0)
          return false;
      }
      if (sum != 0)
        return false;
    }
    return true;
  };
  reverse(all(d));
  for (int x : d)
    if (check(x)) {
      cout << x << endl;
      return 0;
    }
  return 0;
}