The particle は marks the items in contrast(i.e.,N1 and N2). The particles を and が in the original sentences are replaced by は, whereas particles such as に and へ are not replaced by は, but precede は and form the multiple particles には, へは, and so on. も acts like は and forms the multiple particles にも and へも when used with に and へ, respectively.
えんぴつは ありますが、ボールペンは ありません。
I have a pencil, but I don't have a ball-point pen.
コーヒーは のみますが、こうちゃは のみません。
I drink coffee, but I don't drink black tea.
本やへは 行きませんが、ゆうびんきょくへは 行きます。
I'm not going to a bookstore, but I'm going to the post office.
としょしつには でんわが ありませんが、じむしつには あります。しょくどうにも あります。
There is no telephone in the library [room], but there are some in the administrative office. There is one in the cafeteria, too.