Chanwoo stacks N paper cups into one tower. He thinks a triangle is too hard to build, so the tower runs straight up and down. A single cup has the shape below.

One cup is A+B tall. When a cup is nested onto a cup that faces the same way, the upper cup sinks B into the lower one, so the tower grows by only A. Two neighbouring cups that face opposite ways meet rim to rim or base to base and do not nest, so the two parts simply add their heights.
Six cups stacked in the pattern )(())) look like this.

With A=8 and B=36, that tower is 156mm tall.
Chanwoo can choose the direction of every cup. Write a program that finds every tower height Chanwoo can build with N cups.