Wrote a template function for subtracting element in array