Deductions & credits

I 'm not sure what you mean you sometimes get a gain and other times a loss.  The instructions state to combine your gains/losses  and enter the results on line 1.  The instructions also state to  complete the worksheet only once. 

 

With regard to the "foreign dividends and lt cap. gains",  it is referring to the "capital gains distributions" from the 1099-DIV, box 2a that are foreign sourced.