1 of 4
user avatar
user avatar
Jelly, 16 bytes
’ÆRṡ2_/2+$$ÐḟFİS
While trying to improve my previous answer, I thought up a totally different algorithm, and it comes in somewhat shorter. I'm using a different post for it, as is the standard here for an answer that uses a different technique.
(EDIT: Deleting, it's too close to Dennis' answer which was posted while I was working on this.)
user62131