The general rule in the US is that you clear at first airport. However, in certain cases e.g. Bangor, they will give you a permit to continue to destination. That said if you are coming from Europe, it is generally less of a hassle to land on the Canadian side (YQX, YYR, YHZ etc), and continue. The further inland you go into the US the higher the hassle factor. BGR are pretty used to this kind of traffic and know the procedure.
Donīt expect same further down the line.