works for very small n