There is an obligation to add on to the Shabbos at its onset and upon its conclusion.
The Rosh writes that we do not know the exact amount that one is required to add.
The Arizal writes that the total amount of Shabbos, including the additions at its onset and upon its conclusion, should be thirty-one hours.
It is unclear where this amount comes from. Some say that a hint to this can be found in the fact that the Rambam counts the mitzvah of Shabbos as the thirty-first mitzvah in the Torah.
The Bnei Yissochar suggests the following possible reason for this. Shabbos is referred to in the Torah as a day of holiness. We find that a fifth is added to holy articles. An ordinary Shabbos day would consist of twenty-four hours. If we would add a fifth, we would have thirty hours.
Our Gemora teaches the following: Rav Pappa notes that by the fact that the braisa ruled that a kor constitutes an excessive burden for a boat, and that three kors are regarded as an excessive burden for a large ship, it can be derived that an average boat carries a load of thirty kors (for the Mishna taught us that 1/30th more than a usual load will be regarded as an excessive load).
Accordingly, we can say that we desired to add on to the Shabbos an addition that would not be regarded as an excessive burden. If the regular Shabbos day is thirty hours, one additional hour is added, for more than 1/30th would be regarded as excessive. It is because of this that the total amount of hours of Shabbos observance, according to the Arizal, is thirty-one!