public static String toANF( ArrayList<Integer> a, int n )
    {
        int x = ( n <= 5 ) ? 1 : (int)Math.pow( 2, n - 5 );
        int y = ( n < 5 ) ? (int)Math.pow(2,n) : 32;
        int[] ii = new int[x];
        String s = "";
        int c = 0;
        for( int i = 0; i < x; i++ )
        {
            s = "";
            for( int j = 0; j < y; j++ )
            {
                if( a.contains( (c++) ) )
                {
                    s += "1";
                }
                else
                {
                    s += "0";
                }
            }
            ii[i] = Integer.parseInt( s, 2 );
        }
        return ANFParser.parse( ii, n );
    }