The present invention provides a novel compound having antiviral activity, especially HIV replication inhibitory activity and a medicament containing the same. The compound represented by the formula: wherein A 3 is CR 3A , CR 3A R 3B , N or NR 3C ; R 3A , R 3B , R 4A and R 4B are each independently a hydrogen atom, halogen, cyano, substituted or unsubstituted alkyl, substituted or unsubstituted alkynyl, or substituted or unsubstituted non-aromatic carbocyclyl; R 3C is a hydrogen atom, substituted or unsubstituted alkyl, or substituted or unsubstituted non-aromatic carbocyclyl; ring T 1 is substituted or unsubstituted nitrogen-containing non-aromatic heterocycle; R 1 is a hydrogen atom, halogen, cyano, or substituted or unsubstituted alkyl; R 2 is each independently substituted or unsubstituted alkyl or the like: n is 1 or 2; R 3 is substituted or unsubstituted aromatic carbocyclyl or the like; R 4 is a hydrogen atom or a carboxy protecting group.