Compute the sum of an arithmetic series from term count and first and last terms.
輸入項數 n、首項 a₁ 與末項 aₙ,求前 n 項和。