Loading Similar Posts
https://www.geeksforgeeks.org/maximum-sum-subarray-such-that-start-and-end-values-are-same/
Find the prefix Sum.
For each i, check if pref_sum[i] - arr[i] element is present int he prefix sum array which can be done using lower bound. and if its there then check the prev index element in the array if its equal to arr[i], then increment the ans.
T.c. O(nLogn). Do reply if it can be done in O(N) .