Enumeration of variables in function definition

I have variables enumerated by square parentheses: x[i], however I am unable to define a function by these variables:

f[x[1]_]:= x[1]^2

This doesn’t work. What can be done? Thanks.

f[x_[y_]] := x[y]^2