In order to better assist you, please provide the following information;
1) When was the house in Maine sold?
2) Did you live in the Maine house 2 out of the 5 years prior to the year of sale? The two years did not have to be consecutive months.
There are strict guidelines regarding the home sale exclusion. IRS Pub 523 provides detailed information regarding the sale of a home and the exclusion amount. In order to qualify for the home sale exclusion, the following requirements must be met;
Eligibility Step 2—Ownership Determine whether you meet the ownership requirement. If you owned the home for at least 24 months (2 years) during the last 5 years leading up to the date of sale (date of the closing), you meet the ownership requirement.
Determine whether you meet the residence requirement. If your home was your residence for at least 24 of the months you owned the home during the 5 years leading up to the date of sale, you meet the residence requirement. The 24 months of residence can fall anywhere within the 5-year period. It doesn't even have to be a single block of time. All you need is a total of 24 months (730 days) of residence during the 5-year period.
Main Home If you own or live in more than one home, the test for determining which one is your main home is a “facts and circumstances” test. The most important factor is where you spend the most time. However, other factors can enter the picture as well. The more of these that are true of a home, the more likely it is your main home: The address listed on your: 1. U.S. Postal Service address, 2. Voter Registration Card, 3. Federal and state tax returns, and 4. Driver's license or car registration. The home is near: 1. Where you work, 2. Where you bank, 3. The residence of one or more family members, and 4. Recreational clubs or religious organizations of which you are a member.
Link to IRS Pub 523: