Triangle for cotangent complexes of rings