public static void Pick(IStackList <object> stack) { if (stack.HasA <int>()) { var i = stack.Pop <int>(); if (i > stack.Count) { var obj = stack[i]; stack.Remove(obj); stack.Push(obj); } else { stack.Push(i); } } }