n=int(input()) a=[int(i) for i in input().split(" ")] def ret(num,li): count=0 if num<3:return count for i in range(num-2): for e in range(i+1,num-1): for p in range(e+1,num): if (li[i]-li[e])*(li[p]-li[e])*abs(li[i]-li[p])>0: count+=1 return count print(ret(n,a))