static int[] randomSortedIntArray(int n) { new IntBuffer buf; for i to n: if (tossCoin(random)) buf.add(i+1); int[] a = buf.toArray(); }