Problem: A group of n friends enjoys playing popular video game Toda 2. There is a rating system describing skill level of each player, initially the rating of the i-th friend is ri.

The friends decided to take part in the championship as a team. But they should have equal ratings to be allowed to compose a single team consisting of all n friends. So the friends are faced with the problem: how to make all their ratings equal.

One way to change ratings is to willingly lose in some matches. Friends can form a party consisting of two to five (but not more than n) friends and play a match in the game. When the party loses, the rating of each of its members decreases by 1. A rating can't become negative, so ri = 0 doesn't change after losing.

The friends can take part in multiple matches, each time making a party from any subset of friends (but remember about constraints on party size: from 2 to 5 members).

The friends want to make their ratings equal but as high as possible.

Help the friends develop a strategy of losing the matches so that all their ratings become equal and the resulting rating is maximum possible.

Input

The first line contains a single integer n (2 ≤ n ≤ 100) — the number of friends.

The second line contains n non-negative integers r1, r2, ..., rn (0 ≤ ri ≤ 100), where ri is the initial rating of the i-th friend.

Output

In the first line, print a single integer R — the final rating of each of the friends.

In the second line, print integer t — the number of matches the friends have to play. Each of the following t lines should contain n characters '0' or '1', where the j-th character of the i-th line is equal to:

  * '0', if friend j should not play in match i, 
  * '1', if friend j should play in match i. 



Each line should contain between two and five characters '1', inclusive.

The value t should not exceed 104, it is guaranteed that such solution exists. 

Remember that you shouldn't minimize the value t, but you should maximize R. If there are multiple solutions, print any of them.

Examples

Input

5
4 5 1 7 4


Output

1
8
01010
00011
01010
10010
00011
11000
00011
11000


Input

2
1 2


Output

0
2
11
11


Input

3
1 1 1


Output

1
0

Solution (in JAVA):

Solution:
import java.util.*;

public class q11
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		ArrayList<Integer> ratings = new ArrayList<Integer>();
		int total = 0;
		int temp=0;
		int min = Integer.MAX_VALUE;
		for(int n=0;n<N;n++)
		{
			temp = in.nextInt();
			ratings.add(temp);
			total+=temp;
			if(min>temp)
				min = temp;
		}

		
		
		int[] residual = new int[N];
		for(int i=0;i<N;i++)
		{
			residual[i]=ratings.get(i)-min;
		}
		//System.out.println("outside");
		//printArray(residual);
		while(true)
		{
			if(cal(residual,min))
			{

				break;
			}
			else
			{
				//System.out.println("whast going on?");
				//printArray(residual);
				residual = incr(residual,min);
				if(min!=0)min--;
			}
		}

	}
		public static int[] incr(int[] residual,int min)
		{
			if(min!=0)
			{
			for(int i=0;i<residual.length;i++)
				residual[i]++;
			}
			else
			{
				int maxI = ArMax(residual);
				for(int i=0;i<residual.length;i++)
					if(maxI!=i)
						residual[i]++;
			}
			return residual;
		}

	
		public static boolean cal(int[] res,int min)
		{
			int[] residual = new int[res.length];
			for(int i=0;i<res.length;i++)
			{
				residual[i] = res[i];
			}
			//printArray(residual);
			int[][] arr = new int[10000][residual.length+1];
			int arrRows = 0;
			int arrPoint = 0;
			int totalOnes=0;
			int totalNonOnes = 0;
			int total = 0;
			int count =0;
		/*	int[] a = new int[residual.length];
			int[] tempResidual = new int[residual.length];
			for(int i=0;i<residual.length;i++)
				tempResidual[i] = residual[i];
			Arrays.sort(tempResidual);
			a[0] = tempResidual[0];
			for(int i=1;i<residual.length;i++)
			{
				a[i] = tempResidual[i]-tempResidual[i-1];
			}*/
			int tt=0;
			int maxI = ArMax(residual);
			for(int i=0;i<residual.length;i++)
			{
				if(i==maxI)
					tt-=residual[i];
				else
					tt+=residual[i];
			}
			



/*			for(int i=0;i<a.length;i++)
			{
				if((residual.length - i) >=5)
				{
					tt+=a[i]*(5-2);
				}
				else
				{
					tt+=a[i]*((residual.length-i)-2);
				}
			}*/			
			
			//System.out.println("totalOnes " +totalOnes);
		//	System.out.println("totalNonOnes " +totalNonOnes);
			if(tt<0)return false;         //cant be done with this residual array
				else
				{


            for(int i=0;i<residual.length;i++)
			{
				total+=residual[i];
			}
			while(total!=0)
			{
				arrRows++;
				count=0;
				for(int i=0;i<residual.length && count<5;i++)
				{
					if(residual[i]!=0)
					{	
						residual[i]--;
						arr[arrPoint][i] = 1;
						count++;
						total--;
					}

				}
				arr[arrPoint][residual.length] = count;

				arrPoint++;
				/*if(count==1)totalOnes++;
				else 
				{
					totalNonOnes = totalNonOnes + count-2;
				}*/
				

			}
			//if(totalOnes>totalNonOnes)return false;
			//assert totalOnes>totalNonOnes :"assert statement";
			/*if(totalOnes>totalNonOnes)
				{
					System.out.println("NOOO");
					System.out.println("totalOnes " +totalOnes);
					System.out.println("totalNonOnes " +totalNonOnes);
					System.out.println("tt " +tt);
				}*/
			
			


					int arrOnePoint = 0;
					int arrMoreThanTwoPoint = 0;
					int k=0;
					while(arr[arrOnePoint][residual.length]!=1 )
					{
						arrOnePoint++;
			//			System.out.println("cehck here " +arrRows);
						if(arrOnePoint>=arrRows)
							break;
						
					}
					//System.out.println("arroNepint " +arrOnePoint);
					while(arrOnePoint<arrRows)
					{
						while(arr[arrMoreThanTwoPoint][residual.length]<=2)
							arrMoreThanTwoPoint++;
						for(int i=0;i<residual.length;i++)
						{
							if(arr[arrMoreThanTwoPoint][i]==1 && arr[arrOnePoint][i]==0)
							{
							arr[arrMoreThanTwoPoint][i]=0;
							arr[arrOnePoint][i] = 1;
							arr[arrMoreThanTwoPoint][residual.length]-=1;
							arr[arrOnePoint][residual.length] = 2;
							arrOnePoint++;
							

							break;
							}
						}
						//print2DArray(arr);
					}
				//	System.out.println("chgec thos out");
				//	print2DArray(arr);

					System.out.println(min);
					System.out.println(arrRows);
					for(int i=0;i<arrRows;i++)
					{	
						for(int j=0;j<residual.length;j++)
						{	
							System.out.print(arr[i][j]);
						}
						System.out.println();
					}
				return true;

				}

			
			
		}
		public static int ArMax(int[] arr)
		{
			int max = 0;
			for(int i=1;i<arr.length;i++)
			{
				if(arr[max]<arr[i])
					max=i;
			}
			return max;

		}	
		public static void printArray(int[] r)
		{
			System.out.println("this is resiudal array");
			for(int i=0;i<r.length;i++)
			{
				System.out.print(r[i] +" ");
			}
		}
		public static void print2DArray(int[][] r)
		{
			for(int i=0;i<5;i++)
			{
				for(int j=0;j<r[0].length;j++)
					System.out.print(r[i][j] +" ");
				System.out.println();
			}
		}


}