Where,

F = Force

i = Current

g = Length of the gap between the solenoid and a piece of metal

a = Area

n = Number of turns

μ0 = 4 x PI x 10-7