Linear-Time Demonstration Selection for In-Context Learning via Gradient Estimation