To spend this amount of days or more in Spain legally, you'll need a temporary residence visa, which will allow you to say in Spain for up to 1 year, renewable every 2 years for up to 5 years under certain conditions. These will depend on whether you will be financially self-sufficient or not.