Ellis drives in 3 runs as A's avoid sweep