The present invention relates to compounds of formula (1) or pharmaceutical acceptable salts, wherein R1, X, Y, Z, A, B, G1, and n are defined in the description. The present invention relates also to compositions containing said compounds which are useful for inhibiting kinases such as ALK and methods of treating diseases such as cancer.