Pairwise different distances

EOlymp - 652