p=[[]]for n in input():p+=[x+[n][:2>len(x)or n-x[-1]==x[1]-x[0]]for x in p]print max(p,key=len)
[5,4,2,-1,-2,-4,-4]
[5, 2, -1, -4]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!