Step 1: Understand sign-magnitude representation.
In sign-magnitude representation:
-- 1 bit is used for the sign
-- Remaining $(n-1)$ bits are used for the magnitude
So, the range of values representable by an $n$-bit sign-magnitude number is:
\[
-(2^{n-1}-1) \;\text{to}\; +(2^{n-1}-1)
\]
Step 2: Analyze the subtraction $Z = X - Y$.
Subtraction can be rewritten as:
\[
Z = X + (-Y)
\]
The worst-case magnitude of $Z$ occurs when:
-- $X$ is the largest positive number, and
-- $Y$ is the largest negative number.
That is:
\[
X = +(2^{n-1}-1), \quad Y = -(2^{n-1}-1)
\]
Step 3: Compute the maximum possible value of $Z$.
\[
Z_{\max} = (2^{n-1}-1) - (-(2^{n-1}-1)) = 2 \times (2^{n-1}-1)
\]
\[
Z_{\max} = 2^n - 2
\]
Step 4: Determine the number of bits required.
To represent a magnitude close to $2^n$, we need $n$ magnitude bits.
Including the sign bit, the total number of bits required is:
\[
n + 1
\]
Step 5: Conclusion.
To avoid overflow in sign-magnitude representation, $Z$ must be represented using
\[
\boxed{n+1 \text{ bits}}
\]