There are 1001 stacks of coins S1, S2, ..., S1001. Initially, stack Sk has k coins for each k = 1,2, ...,1001. In an operation, one selects an ordered pair (i,j) of indices i and j satisfying 1 ≤ i < j ≤ 1001 subject to two conditions:
The stacks Si and Sj must each have at least 1 coin.
The ordered pair (i,j) must not have been selected before.
Then, if Si and Sj have a coins and b coins respectively, one removes gcd(a,b) coins from each stack.
What is the maximum number of times this operation could be performed?