Finding a pair values from Array getting more length of pairs

I would like to find the pair of array values like this:

  1. 1+2 = 3
  2. 1+2 = 3
  3. 3+6 = 9
  4. 2+1 = 3
  5. 1+2 = 3

for I try like this:

const ar = [1, 3, 2, 6, 1, 2], n = 6, k = 3;
    const list = [];
    
    const filter = (num) => {
      const v = ar.filter(v => {
        if((num+v) %3 === 0){
          list.push([num, v]);
        }
      });
    
    }
    
    for(let i = 0; i < n; i++) {
      const val = ar[i]
      filter(val)
    }
    
   console.log(list); 

But gives more pairs[12] than required length. How to handle this? I understood I lost some logic here.