1 #include <iostream> 2 #include <string.h> 3 #include <string> 4 #include <fstream> 5 #include <algorithm> 6 #include <stdio.h> 7 #include <vector> 8 #include <queue> 9 using namespace std; 10 #define MAXN 10002 11 int main() 12 { 13 int n; 14 while(scanf("%d",&n),n!=0) 15 { 16 int a[MAXN]; 17 for(int i=0;i<n;i++) 18 { 19 scanf("%d",&a[i]); 20 } 21 sort(a,a+n); 22 int k=1,maxk=-1; 23 for(int i=1;i<n;i++) 24 { 25 if(a[i]==a[i-1])k++; else k=1; 26 if(k>maxk)maxk=k; 27 } 28 queue<int> q[MAXN]; 29 k=0; 30 for(int i=0;i<n;i++) 31 { 32 q[k].push(a[i]); 33 k=(k+1)%maxk; 34 } 35 36 printf("%d ",maxk); 37 for(int i=0;i<maxk;i++) 38 { 39 40 while(!q[i].empty()) 41 {if(q[i].size()==1)printf("%d",q[i].front()); 42 else 43 printf("%d ",q[i].front());q[i].pop();} 44 printf(" "); 45 } 46 printf(" "); 47 } 48 49 50 return 0; 51 }