#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)
typedef long long ll;
const int N = 500500;
const int mod = 1e9 + 7;
int n, s, a[N];
vector<int> d;
int ans[N];
map<int, int> w;
inline int solve(int k) {
int one = s / k, curs = 0, res = 0;
w.clear();
curs = w[0] = 0;
for(int i = 1; i <= n; ++i) {
curs += a[i];
if(w.count(curs - one)) {
w[curs] = w[curs - one] + 1;
if(i < n && k - 1 == w[curs] || i == n && k == w[curs]) return 1;
} else w[curs] = 0;
}
return 0;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> n;
fo(i, n) cin >> a[i], s += a[i];
if(s == 0) {
fo(i, n) cout << 1;
return 0;
}
fo(i, n) a[i + n] = a[i];
for(int i = 1; i * i <= s; ++i)
if(s % i == 0) {
d.pb(i);
if(i * i != s) d.pb(s / i);
}
for(int one : d) {
int k = s / one;
if(k <= n) ans[k] = solve(k);
}
fo(i, n) cout << ans[i];
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIAojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGZvKGksIG4pIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKQogCnR5cGVkZWYgbG9uZyBsb25nIGxsOwogCmNvbnN0IGludCBOID0gNTAwNTAwOwpjb25zdCBpbnQgbW9kID0gMWU5ICsgNzsKIAppbnQgbiwgcywgYVtOXTsKdmVjdG9yPGludD4gZDsKaW50IGFuc1tOXTsKIAptYXA8aW50LCBpbnQ+IHc7CiAKaW5saW5lIGludCBzb2x2ZShpbnQgaykgewogICAgaW50IG9uZSA9IHMgLyBrLCBjdXJzID0gMCwgcmVzID0gMDsKICAgIHcuY2xlYXIoKTsKICAgIGN1cnMgPSB3WzBdID0gMDsKICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSAgewogICAgICAgIGN1cnMgKz0gYVtpXTsKICAgICAgICBpZih3LmNvdW50KGN1cnMgLSBvbmUpKSB7CiAgICAgICAgICAgIHdbY3Vyc10gPSB3W2N1cnMgLSBvbmVdICsgMTsKICAgICAgICAgICAgaWYoaSA8IG4gJiYgayAtIDEgPT0gd1tjdXJzXSB8fCBpID09IG4gJiYgayA9PSB3W2N1cnNdKSByZXR1cm4gMTsKICAgICAgICB9IGVsc2Ugd1tjdXJzXSA9IDA7CiAgICB9CiAgICByZXR1cm4gMDsKfQogCmludCBtYWluKCkgewogCiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsgY2luLnRpZSgwKTsKICAgIGNpbiA+PiBuOwogICAgZm8oaSwgbikgY2luID4+IGFbaV0sIHMgKz0gYVtpXTsKICAgIGlmKHMgPT0gMCkgewogICAgICAgIGZvKGksIG4pIGNvdXQgPDwgMTsKICAgICAgICByZXR1cm4gMDsKICAgIH0KICAgIGZvKGksIG4pIGFbaSArIG5dID0gYVtpXTsKICAgIGZvcihpbnQgaSA9IDE7IGkgKiBpIDw9IHM7ICsraSkKICAgICAgICBpZihzICUgaSA9PSAwKSB7CiAgICAgICAgICAgIGQucGIoaSk7CiAgICAgICAgICAgIGlmKGkgKiBpICE9IHMpIGQucGIocyAvIGkpOwogICAgICAgIH0KICAgIGZvcihpbnQgb25lIDogZCkgewogICAgICAgIGludCBrID0gcyAvIG9uZTsKICAgICAgICBpZihrIDw9IG4pIGFuc1trXSA9IHNvbHZlKGspOwogICAgfQogICAgZm8oaSwgbikgY291dCA8PCBhbnNbaV07CiAgICByZXR1cm4gMDsKfQ==