#include <stdio.h>
#include <vector>
#include <string>
#include <functional>
#include <cassert>
#include <cstdlib>
std::string solve(const std::vector<int>& a) {
const int n = a.size();
int sum = 0;
for (auto& it : a) {
assert(it >= 0);
sum += it;
}
assert(0 <= sum && sum <= 1e9);
if (sum == 0) {
return std::string(n, '1');
}
std::function<bool(int)> is_possible = [&](int number) {
const int need_sum = sum / number;
assert(need_sum * number == sum);
// Найдем такой отрезок [l, r), (0 <= l < r < n), сумма в котором равна need_sum:
int r = 0, l = 0, curr_sum = 0, rem = sum;
while (l < n) {
while (r < n && curr_sum + a[r] <= need_sum) {
curr_sum += a[r];
++r;
}
if (curr_sum == need_sum) {
break;
}
curr_sum -= a[l];
++l;
}
if (curr_sum != need_sum) {
return false;
}
rem -= need_sum;
assert(0 <= l && l < r && r <= n);
// Найдем все оставшиеся отрезки:
--number, curr_sum = 0;
int i = r % n;
while (i != l) {
curr_sum += a[i];
if (curr_sum > need_sum) {
return false;
} else if (curr_sum == need_sum) {
--number;
rem -= need_sum;
curr_sum = 0;
}
++i;
if (i >= n) {
i -= n;
}
}
assert(rem == 0 && number == 0 && curr_sum == 0);
return true;
};
std::string answ(n, '0');
for (int i = 1; i * i <= sum; ++i) {
const int j = sum / i;
if (j * i == sum) {
if (i <= n) {
assert(answ[i-1] == '0');
answ[i-1] += is_possible(i);
}
if (j <= n && j != i) {
assert(answ[j-1] == '0');
answ[j-1] += is_possible(j);
}
}
}
assert(answ[0] == '1');
return answ;
}
int main() {
int n;
scanf("%d", &n);
std::vector<int> a(n);
for (auto& it : a) {
scanf("%d", &it);
}
printf("%s\n", solve(a).c_str());
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxmdW5jdGlvbmFsPgojaW5jbHVkZSA8Y2Fzc2VydD4KI2luY2x1ZGUgPGNzdGRsaWI+CgpzdGQ6OnN0cmluZyBzb2x2ZShjb25zdCBzdGQ6OnZlY3RvcjxpbnQ+JiBhKSB7CiAgICBjb25zdCBpbnQgbiA9IGEuc2l6ZSgpOwogICAgaW50IHN1bSA9IDA7CiAgICBmb3IgKGF1dG8mIGl0IDogYSkgewogICAgICAgIGFzc2VydChpdCA+PSAwKTsKICAgICAgICBzdW0gKz0gaXQ7CiAgICB9CiAgICBhc3NlcnQoMCA8PSBzdW0gJiYgc3VtIDw9IDFlOSk7CiAgICBpZiAoc3VtID09IDApIHsKICAgICAgICByZXR1cm4gc3RkOjpzdHJpbmcobiwgJzEnKTsKICAgIH0KICAgIHN0ZDo6ZnVuY3Rpb248Ym9vbChpbnQpPiBpc19wb3NzaWJsZSA9IFsmXShpbnQgbnVtYmVyKSB7CiAgICAgICAgY29uc3QgaW50IG5lZWRfc3VtID0gc3VtIC8gbnVtYmVyOwogICAgICAgIGFzc2VydChuZWVkX3N1bSAqIG51bWJlciA9PSBzdW0pOwogICAgICAgIC8vINCd0LDQudC00LXQvCDRgtCw0LrQvtC5INC+0YLRgNC10LfQvtC6IFtsLCByKSwgKDAgPD0gbCA8IHIgPCBuKSwg0YHRg9C80LzQsCDQsiDQutC+0YLQvtGA0L7QvCDRgNCw0LLQvdCwIG5lZWRfc3VtOgogICAgICAgIGludCByID0gMCwgbCA9IDAsIGN1cnJfc3VtID0gMCwgcmVtID0gc3VtOwogICAgICAgIHdoaWxlIChsIDwgbikgewogICAgICAgICAgICB3aGlsZSAociA8IG4gJiYgY3Vycl9zdW0gKyBhW3JdIDw9IG5lZWRfc3VtKSB7CiAgICAgICAgICAgICAgICBjdXJyX3N1bSArPSBhW3JdOwogICAgICAgICAgICAgICAgKytyOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjdXJyX3N1bSA9PSBuZWVkX3N1bSkgewogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3Vycl9zdW0gLT0gYVtsXTsKICAgICAgICAgICAgKytsOwogICAgICAgIH0KICAgICAgICBpZiAoY3Vycl9zdW0gIT0gbmVlZF9zdW0pIHsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICByZW0gLT0gbmVlZF9zdW07CiAgICAgICAgYXNzZXJ0KDAgPD0gbCAmJiBsIDwgciAmJiByIDw9IG4pOwogICAgICAgIC8vINCd0LDQudC00LXQvCDQstGB0LUg0L7RgdGC0LDQstGI0LjQtdGB0Y8g0L7RgtGA0LXQt9C60Lg6CiAgICAgICAgLS1udW1iZXIsIGN1cnJfc3VtID0gMDsKICAgICAgICBpbnQgaSA9IHIgJSBuOwogICAgICAgIHdoaWxlIChpICE9IGwpIHsKICAgICAgICAgICAgY3Vycl9zdW0gKz0gYVtpXTsKICAgICAgICAgICAgaWYgKGN1cnJfc3VtID4gbmVlZF9zdW0pIHsKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfSBlbHNlIGlmIChjdXJyX3N1bSA9PSBuZWVkX3N1bSkgewogICAgICAgICAgICAgICAgLS1udW1iZXI7CiAgICAgICAgICAgICAgICByZW0gLT0gbmVlZF9zdW07CiAgICAgICAgICAgICAgICBjdXJyX3N1bSA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgKytpOwogICAgICAgICAgICBpZiAoaSA+PSBuKSB7CiAgICAgICAgICAgICAgICBpIC09IG47CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYXNzZXJ0KHJlbSA9PSAwICYmIG51bWJlciA9PSAwICYmIGN1cnJfc3VtID09IDApOwogICAgICAgIHJldHVybiB0cnVlOwogICAgfTsKICAgICAKICAgIHN0ZDo6c3RyaW5nIGFuc3cobiwgJzAnKTsKICAgICAKICAgIGZvciAoaW50IGkgPSAxOyBpICogaSA8PSBzdW07ICsraSkgewogICAgICAgIGNvbnN0IGludCBqID0gc3VtIC8gaTsKICAgICAgICBpZiAoaiAqIGkgPT0gc3VtKSB7CiAgICAgICAgICAgIGlmIChpIDw9IG4pIHsKICAgICAgICAgICAgICAgIGFzc2VydChhbnN3W2ktMV0gPT0gJzAnKTsKICAgICAgICAgICAgICAgIGFuc3dbaS0xXSArPSBpc19wb3NzaWJsZShpKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoaiA8PSBuICYmIGogIT0gaSkgewogICAgICAgICAgICAgICAgYXNzZXJ0KGFuc3dbai0xXSA9PSAnMCcpOwogICAgICAgICAgICAgICAgYW5zd1tqLTFdICs9IGlzX3Bvc3NpYmxlKGopOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgYXNzZXJ0KGFuc3dbMF0gPT0gJzEnKTsKICAgIHJldHVybiBhbnN3Owp9CgppbnQgbWFpbigpIHsKICAgIGludCBuOwogICAgc2NhbmYoIiVkIiwgJm4pOwogICAgc3RkOjp2ZWN0b3I8aW50PiBhKG4pOwogICAgZm9yIChhdXRvJiBpdCA6IGEpIHsKICAgICAgICBzY2FuZigiJWQiLCAmaXQpOwogICAgfQogICAgcHJpbnRmKCIlc1xuIiwgc29sdmUoYSkuY19zdHIoKSk7CiAgICByZXR1cm4gMDsKfQ==