def three_sum(array):
res = set()<EOL>array.sort()<EOL>for i in range(len(array) - <NUM_LIT:2>):<EOL><INDENT>if i > <NUM_LIT:0> and array[i] == array[i - <NUM_LIT:1>]:<EOL><INDENT>continue<EOL><DEDENT>l, r = i + <NUM_LIT:1>, len(array) - <NUM_LIT:1><EOL>while l < r:<EOL><INDENT>s = array[i] + array[l] + array[r]<EOL>if s > <NUM_LIT:0>:<EOL><INDENT>r -= <NUM_LIT:1><EOL><DEDENT>elif s < <NUM_LIT:0>:<EOL><INDENT>l += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>res.add((array[i], array[l], array[r]))<EOL>while l < r and array[l] == array[l + <NUM_LIT:1>]:<EOL><INDENT>l += <NUM_LIT:1><EOL><DEDENT>while l < r and array[r] == array[r - <NUM_LIT:1>]:<EOL><INDENT>r -= <NUM_LIT:1><EOL><DEDENT>l += <NUM_LIT:1><EOL>r -= <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>return res<EOL>
:param array: List[int]
:return: Set[ Tuple[int, int, int] ]