#include <bits/stdc++.h>
#define int long long
#define INT_MAX LLONG_MAX
#define INT_MIN LLONG_MIN
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int32_t main () {
fastio();
int t, n, rem;
t = 1;
while (t--) {
cin >> n;
vector<int> arr(n), cnt(3, 0);
for (int i = 0; i < n; i++) {
cin >> arr[i];
cnt[arr[i]%3]++;
}
if (cnt[0] <= n/2) {
cout << 0 << '\n';
rem = n/2 - cnt[0];
for (int i = 0; i < n; i++) {
if (arr[i]%3 == 0) {
cout << 0;
}
else {
if (rem) {
cout << 0;
rem--;
}
else {
cout << 1;
}
}
}
cout << '\n';
}
else if (cnt[1]+cnt[2] <= n/2) {
cout << 2 << '\n';
rem = n/2 - (cnt[1]+cnt[2]);
for (int i = 0; i < n; i++) {
if (arr[i]%3 == 1 || arr[i]%3 == 2) {
cout << 0;
}
else {
if (rem) {
cout << 0;
rem--;
}
else {
cout << 1;
}
}
}
cout << '\n';
}
else {
cout << -1 << '\n';
}
}
return 0;
}
1671D - Insert a Progression | 1671A - String Building |
1671B - Consecutive Points Segment | 1671C - Dolce Vita |
1669G - Fall Down | 4D - Mysterious Present |
1316B - String Modification | 1204A - BowWow and the Timetable |
508B - Anton and currency you all know | 1672A - Log Chopping |
300A - Array | 48D - Permutations |
677C - Vanya and Label | 1583B - Omkar and Heavenly Tree |
1703C - Cypher | 1511C - Yet Another Card Deck |
1698A - XOR Mixup | 1702E - Split Into Two Sets |
1703B - ICPC Balloons | 1702F - Equate Multisets |
1700A - Optimal Path | 665C - Simple Strings |
1708A - Difference Operations | 1703E - Mirror Grid |
1042A - Benches | 1676B - Equal Candies |
1705B - Mark the Dust Sweeper | 1711A - Perfect Permutation |
1701B - Permutation | 1692A - Marathon |