avoid overflow for N > 32768