The present invention relates to a compound of formula (VIa): or a pharmaceutically acceptable s alt or solvate thereof, wherein Ring A is pyrazinyl and L 1 , R 1 , R 1a , R 4 , L 2 , R 2 , R 3 , w and n are as defined herein. Such compounds are glucokinase agonists and useful in the treatment of diseases including diabetes and obesity.