There are 1 * 3 = <<1*3=3>>3 blocks in the second layer.
There are 3 * 3 = <<3*3=9>>9 blocks in the third layer.
There are 9 * 3 = <<9*3=27>>27 blocks in the fourth layer.
Thus, there are 1 + 3 + 9 + 27 = <<1+3+9+27=40>>40 sandstone blocks in the pyramid.
#### 40