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;
int dp[35][105][((105) * (105 + 1)) / 2];
int dir[35][105][((105) * (105 + 1)) / 2];
int n, ara[35];
int solve(int now, int k, int sum) {
  if ((k * (k - 1)) / 2 > sum) return 105;
  if (now == n) {
    if (sum == (k * (k - 1)) / 2) return 0;
    return 105;
  }
  int &ret = dp[now][k][sum];
  if (ret != -1) return ret;
  ret = 105;
  for (int i = 1; k + i < 105; i++) {
    if (i >= ret) break;
    int tmp = i + solve(now + 1, k + i, sum + i * ara[now]);
    if (tmp < ret) {
      ret = tmp;
      dir[now][k][sum] = i;
    }
  }
  return ret;
}
int deg[105];
void go(int now, int k, int sum) {
  if (now == n) return;
  for (int i = 0; i < dir[now][k][sum]; i++) deg[k + i] = ara[now];
  go(now + 1, k + dir[now][k][sum], sum + ara[now] * dir[now][k][sum]);
}
const int MAX_E = 60003;
const int MAX_V = 5003;
int ver[MAX_E], cap[MAX_E], nx[MAX_E], last[MAX_V], ds[MAX_V], st[MAX_V],
    now[MAX_V], edge_count, S, T;
inline void reset() {
  memset(nx, -1, sizeof(nx));
  memset(last, -1, sizeof(last));
  edge_count = 0;
}
inline void addedge(const int v, const int w, const int capacity,
                    const int reverse_capacity) {
  ver[edge_count] = w;
  cap[edge_count] = capacity;
  nx[edge_count] = last[v];
  last[v] = edge_count++;
  ver[edge_count] = v;
  cap[edge_count] = reverse_capacity;
  nx[edge_count] = last[w];
  last[w] = edge_count++;
}
inline bool bfs() {
  memset(ds, -1, sizeof(ds));
  int a, b;
  a = b = 0;
  st[0] = T;
  ds[T] = 0;
  while (a <= b) {
    int v = st[a++];
    for (int w = last[v]; w >= 0; w = nx[w]) {
      if (cap[w ^ 1] > 0 && ds[ver[w]] == -1) {
        st[++b] = ver[w];
        ds[ver[w]] = ds[v] + 1;
      }
    }
  }
  return ds[S] >= 0;
}
int dfs(int v, int cur) {
  if (v == T) return cur;
  for (int &w = now[v]; w >= 0; w = nx[w]) {
    if (cap[w] > 0 && ds[ver[w]] == ds[v] - 1) {
      int d = dfs(ver[w], min(cur, cap[w]));
      if (d) {
        cap[w] -= d;
        cap[w ^ 1] += d;
        return d;
      }
    }
  }
  return 0;
}
inline long long flow() {
  long long res = 0;
  while (bfs()) {
    for (int i = 0; i < MAX_V; i++) now[i] = last[i];
    while (1) {
      int tf = dfs(S, 2000000000);
      res += tf;
      if (!tf) break;
    }
  }
  return res;
}
int mat[105][105];
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &ara[i]);
  sort(ara, ara + n);
  memset(dp, -1, sizeof(dp));
  int nd = solve(0, 0, 0);
  if (nd == 105) {
    printf("=(\n");
    return 0;
  }
  go(0, 0, 0);
  reset();
  int cnt = 1, bam = (nd * (nd - 1)) / 2;
  S = 0;
  T = bam + 1 + nd;
  for (i = 0; i < nd; i++) {
    for (j = i + 1; j < nd; j++) {
      addedge(S, cnt, 1, 0);
      addedge(cnt, i + bam + 1, 1, 0);
      addedge(cnt, j + bam + 1, 1, 0);
      cnt++;
    }
  }
  for (i = 0; i < nd; i++) addedge(bam + i + 1, T, deg[i], 0);
  flow();
  cnt = 0;
  for (i = 0; i < nd; i++) {
    for (j = i + 1; j < nd; j++) {
      cnt += 2;
      if (cap[cnt])
        mat[j][i] = 1;
      else
        mat[i][j] = 1;
      cnt += 4;
    }
  }
  printf("%d\n", nd);
  for (i = 0; i < nd; i++) {
    for (j = 0; j < nd; j++) printf("%d", mat[i][j]);
    printf("\n");
  }
  return 0;
}