Compounds having glucokinase activating effects and being useful as treatments for diabetes, which are represented by the following formula (I): (wherein X 1 to X 4 represent a carbon atom, etc., ring A represents a 5- or 6-membered heteroaryl having from 1 to 4 hetero atoms selected from the group consisting of a nitrogen atom, a sulfur atom and an oxygen atom, X 5 represent an oxygen atom, etc., X represent a carbon atom, etc., Het represents a 5- or 6-membered aliphatic hetero ring, R 1 represents aryl, etc., R 2 represents formyl, etc., R 3 represents -C 1-6 alkyl, etc.), as well as their pharmaceutically acceptable salts.