Find common elements in sorted array