Problem: Ivan is reading a book about tournaments. He knows that a tournament is an oriented graph with exactly one oriented edge between each pair of vertices. The score of a vertex is the number of edges going outside this vertex. 

Yesterday Ivan learned Landau's criterion: there is tournament with scores d1 ≤ d2 ≤ ... ≤ dn if and only if <image> for all 1 ≤ k < n and <image>.

Now, Ivan wanna solve following problem: given a set of numbers S = {a1, a2, ..., am}, is there a tournament with given set of scores? I.e. is there tournament with sequence of scores d1, d2, ..., dn such that if we remove duplicates in scores, we obtain the required set {a1, a2, ..., am}? 

Find a tournament with minimum possible number of vertices. 

Input

The first line contains a single integer m (1 ≤ m ≤ 31).

The next line contains m distinct integers a1, a2, ..., am (0 ≤ ai ≤ 30) — elements of the set S. It is guaranteed that all elements of the set are distinct.

Output

If there are no such tournaments, print string "=(" (without quotes).

Otherwise, print an integer n — the number of vertices in the tournament.

Then print n lines with n characters — matrix of the tournament. The j-th element in the i-th row should be 1 if the edge between the i-th and the j-th vertices is oriented towards the j-th vertex, and 0 otherwise. The main diagonal should contain only zeros.

Examples

Input

2
1 2


Output

4
0011
1001
0100
0010


Input

2
0 3


Output

6
000111
100011
110001
011001
001101
000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAX_M = 40;
const int MAX_N = 70;
bool memo[MAX_N][32][32 * MAX_N];
short mark[MAX_N][32][32 * MAX_N];
short parent[MAX_N][32][32 * MAX_N];
int arr[MAX_M];
int n, m;
short pass = 1;
bool mat[MAX_N][MAX_N];
int out[MAX_N];
const int INF = 1e9;
bool roll(int pos, int idx, int sum) {
  if (pos == n + 1) {
    return idx == m + 1 && sum == (1LL * n * (n - 1)) / 2LL;
  } else if (idx == m + 1) {
    return false;
  }
  bool &ans = memo[pos][idx][sum];
  if (mark[pos][idx][sum] == pass) {
    return ans;
  }
  mark[pos][idx][sum] = pass;
  if (sum + arr[idx] >= (1LL * pos * (pos - 1)) / 2) {
    if (roll(pos + 1, idx, sum + arr[idx])) {
      ans = true;
      parent[pos][idx][sum] = idx;
    } else if (roll(pos + 1, idx + 1, sum + arr[idx])) {
      ans = true;
      parent[pos][idx][sum] = idx + 1;
    }
  }
  return ans;
}
int main() {
  scanf("%d", &m);
  for (int i = int(1); i < int(m + 1); i++) {
    scanf("%d", arr + i);
  }
  sort(arr + 1, arr + m + 1);
  memset(parent, -1, sizeof parent);
  int ans = -1;
  for (int i = m; i <= 100 && ans == -1; i++) {
    n = i;
    bool ok = roll(1, 1, 0);
    if (ok) {
      ans = i;
    }
    pass++;
  }
  if (ans == -1) {
    puts("=(");
    return 0;
  }
  tuple<int, int, int> cur = tuple<int, int, int>(1, 1, 0);
  vector<int> els;
  while (get<0>(cur) <= n) {
    int pos, idx, sum;
    tie(pos, idx, sum) = cur;
    els.push_back(arr[idx]);
    tuple<int, int, int> nxt =
        tuple<int, int, int>(pos + 1, parent[pos][idx][sum], sum + arr[idx]);
    cur = nxt;
  }
  set<pair<int, int> > order;
  for (int i = int(0); i < int(n); i++) {
    out[i] = els[i];
    order.emplace(out[i], i);
  }
  n = ans;
  for (int i = int(0); i < int(n); i++) {
    pair<int, int> p = *order.begin();
    order.erase(order.begin());
    vector<pair<int, int> > to_update;
    for (auto &each : order) {
      if (out[p.second] > 0) {
        out[p.second]--;
        mat[p.second][each.second] = true;
      } else {
        out[each.second]--;
        mat[each.second][p.second] = true;
      }
      to_update.emplace_back(out[each.second], each.second);
    }
    order.clear();
    for (auto &each : to_update) {
      order.insert(each);
    }
  }
  printf("%d\n", ans);
  for (int i = int(0); i < int(n); i++) {
    for (int j = int(0); j < int(n); j++) {
      printf("%d", (int)mat[i][j]);
    }
    puts("");
  }
  return 0;
}