An integer n belongs to M if and only if there exists disjoint subsets A, B of the set S={1,2,…,2015}, with A∪B=S, so that −2a+3b=n, where a is the sum of the elements of A and b is the sum of the elements of B (the sum of the elements of the empty set being 0).
Then n=5b−2(a+b) and, since a+b=1+2+⋯+2015, it follows that
n=5b−2015⋅2016.
This shows that n is divisible by 5, hence 2016∈/M.
In order to prove that 2015∈M, it is enough to find B⊂{1,2,…,2015} with the sum of its elements b=51(2015⋅2016+2015)=403⋅2017.
An example is when B is the union of 403 pairs of elements of S with sum 2017, for instance (2,2015), (3,2014), ..., (404,1613).
So, taking x2=x3=⋯=x404=x1613=x1614=⋯=x2015=3 and x1=x405=x406=⋯=x1612=−2, we get 2015∈M.