Original query:

create table multitest as
select base,
       m0,
       m1,
       count(*) coun,
       -99::float c
from
  (select sids
   from sad) foo,
     lateral
  (select distinct unnest(foo.sids) base) base,
             lateral
  (select distinct unnest(foo.sids) m0) m0,
                     lateral
  (select distinct unnest(foo.sids) m1) m1
where base<m0
  and m0<m1
group by base,
         m0,
         m1