I have a large list $L$ of numbers and I need to count instances of elements $a,b,c \in L$ such that $a +c = 2b$. A brute-force approach would be to check all possible triples $(a,b,c)$ and this will run in $L^3$ time.Can I do any better?
counting arithmetic progressions $a, a+r, a+2r$ in a list
algorithms;number theory;lists