Yevamos4: 11
אַרְבָּעָה אַחִין נְשׂוּאִין אַרְבַּע נָשִׁים, וָמֵתוּ — אִם רָצָה הַגָּדוֹל שֶׁבָּהֶם לְיַבֵּם אֶת כֻּלָּן הָרְשׁוּת בְּיָדוֹ.  מִי שֶׁהָיָה נָשׂוּי לִשְׁתֵּי נָשִׁים, וָמֵת — בִּיאָתָהּ אוֹ חֲלִיצָתָהּ שֶׁל אַחַת מֵהֶן פוֹטֶרֶת צָרָתָהּ. הָיְתָה אַחַת כְּשֵׁרָה, וְאַחַת פְּסוּלָה, אִם הָיָה חוֹלֵץ — חוֹלֵץ לַפְּסוּלָה. וְאִם הָיָה מְיַבֵּם — מְיַבֵּם לַכְּשֵׁרָה.
[If] four brothers were married to four women and [then] died, if the eldest of them wished to perform yibum with all of them, he may do so.  [If] someone was married to two women and [then] died, conjugal relations or chalitzah with one of them releases her co-wife. [If] one was qualified and one was disqualified, if he is [going] to perform chalitzah, he should do so with the disqualified one; but if he is [going] to perform yibum, he may do so with the qualified one.