import math
#check if a number is fibonacci
def is_fib(n):
return math.sqrt(5* n**2 + 4 ).is_integer() or math.sqrt(5* n**2 - 4).is_integer()
for i in range(int(input())):
T = int(input())
liste = [i for i in map(int,input().split())]
cnt = 0
arr = {}
for i in range(len(liste)):
for j in range(1,len(liste)):
if is_fib(liste[i]+liste[j]) and (liste[i]+liste[j] not in arr) and liste[i] != liste[j]:
cnt +=1
arr[liste[i]+liste[j]] = liste[i]+liste[j]
print(cnt)
I solved this problem of how many sums of two numbers in a list is a Fibonacci number but I got the time complexity is O(n^2)
How Can I Reduce the time complexity