Still referring to FIG. 5, the first high voltage well 52 is formed on the deep well 511 in the semiconductor layer 51′, and has the second conductivity type. The first high voltage well 52 overlays an upper boundary of the deep well 511 and is in contact with the deep well 511, and the first high voltage well 52 is below and in contact with the top surface 51a in the vertical direction. The first conductivity type well 511′ is formed in the first high voltage well 52 outside the device region 53a, and has the first conductivity type. The first conductivity type well 511′ is located below the top surface 51a and in contact with the top surface 51a in the vertical direction. The first conductivity type well 511′ is in contact with the deep well 511 and is electrically connected to the deep well 511. The second high voltage well 512′ is formed in the first high voltage well 52 outside the device region 53a, and has the second conductivity type. The second high voltage well 512′ is located below the top surface 51a and in contact with the top surface 51a in the vertical direction. The second high voltage well 512′ is in contact with the buried layer 512, and is electrically connected to the buried layer 512.