this is the link to the editorial where u can even find link to the problem.

In editorialist’s approach

why expected value of gcd(a[i],a[j])*k^2=score?

how expected value term comes from score expression?

Thankyou

In editorialist’s approach

why expected value of gcd(a[i],a[j])*k^2=score?

how expected value term comes from score expression?

Thankyou