Find the number of good swaps.

2.2k Views Asked by At

Suppose we are given a positive integer N. Consider the sequence S=(1,2,…,N). You should choose two elements of this sequence and swap them.A swap is nice if there is an integer M (1≤M<N) such that the sum of the first M elements of the resulting sequence is equal to the sum of its last N−M elements. What is the number of nice swaps.