Define a function with a n-dimensional vector X with conditionals?

Dear all,
I need your help in defining a function over a vector as follows.

First, I need to define a n-dimensional vector X, taking n as a variable rather than a particular value.
Second, I need to define a function of X in the following way.
Y(i) = 1 if i = n; Y(i) = X(i) if 1<= i <= n-1; Y(i) = 0 if i = 0.

Any suggestions? Thanks.

Perhaps

f[X_]:=Join[{0},Rest[Most[X]],{1}]

where

f[{1, 2, 3, 5, 7}]

returns {0, 2, 3, 5, 1}

Thanks a lot! It helps.