Compounds of formula (I) or pharmaceutical acceptable salts are provided, wherein X1˜X5, R1˜R3, A, B, Z and n are defined in the description. And compositions containing said compounds, and the uses for inhibitors of kinases such as ALK, and the uses for treating cancer thereof are provided.