What's it supposed to do? If you are counting duplicates, that's not it. Try 2 3 6 2 6 5 5 5 5 to disprove it.
I'm reviewing your algorithm, not your data. I made up my own data.
Why would you need an algorithm to count pairs if the data you provided was the entire universe of data? Just count them. Pair of 2's Pair of 6's. There, 2 pairs. Done.
Should your algorithm work with ANY data, or just some clear subset, such as that you have provided? If it needs to work on ANY data, then you'll get some double counting. If you can guarantee that there never will be a trio or a quartet or worse, then perhaps you are done.