Any person who trespasses on property for the purpose of committing any act, or attempting to commit any act, in violation of Section 631, 632, 632.5, 632.6, 632.7, or 636 shall be punished by a fine not exceeding two thousand five hundred dollars ($2,500), by imprisonment in the county jail not exceeding one year or in the state prison, or by both that fine and imprisonment. If the person has previously been convicted of a violation of this section or Section 631, 632, 632.5, 632.6, 632.7, or 636, the person shall be punished by a fine not exceeding ten thousand dollars ($10,000), by imprisonment in the county jail not exceeding one year or in the state prison, or by both that fine and imprisonment.