




"""simple docstring"""
import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionDualGuidedPipeline
from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device


SCREAMING_SNAKE_CASE_			      =					False
@nightly
@require_torch_gpu
class      lowerCAmelCase_						(							unittest.TestCase				):



							'''simple docstring'''





							def  A__		(				self							)   ->       List[str]:
													super().tearDown()
													gc.collect()
													torch.cuda.empty_cache()




							def  A__		(				self							)   ->       str:
													__lowerCAmelCase        =       VersatileDiffusionDualGuidedPipeline.from_pretrained("""shi-labs/versatile-diffusion"""							)
													# remove text_unet
													pipe.remove_unused_weights()
													pipe.to(__lowerCAmelCase							)
													pipe.set_progress_bar_config(disable=__lowerCAmelCase							)

													__lowerCAmelCase        =       load_image(
													    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"""							)

													__lowerCAmelCase        =       torch.manual_seed(0							)
													__lowerCAmelCase        =       pipe(
													    prompt="""first prompt"""  ,							image=__lowerCAmelCase  ,							text_to_image_strength=0.75  ,							generator=__lowerCAmelCase  ,							guidance_scale=7.5  ,							num_inference_steps=2  ,							output_type="""numpy"""  ,							).images

													with tempfile.TemporaryDirectory() as tmpdirname:
																			pipe.save_pretrained(__lowerCAmelCase							)
																			__lowerCAmelCase        =       VersatileDiffusionDualGuidedPipeline.from_pretrained(__lowerCAmelCase							)

													pipe.to(__lowerCAmelCase							)
													pipe.set_progress_bar_config(disable=__lowerCAmelCase							)

													__lowerCAmelCase        =       generator.manual_seed(0							)
													__lowerCAmelCase        =       pipe(
													    prompt="""first prompt"""  ,							image=__lowerCAmelCase  ,							text_to_image_strength=0.75  ,							generator=__lowerCAmelCase  ,							guidance_scale=7.5  ,							num_inference_steps=2  ,							output_type="""numpy"""  ,							).images

													assert np.abs(image - new_image							).sum() < 1e-5, "Models don't have the same forward pass"




							def  A__		(				self							)   ->       int:
													__lowerCAmelCase        =       VersatileDiffusionDualGuidedPipeline.from_pretrained("""shi-labs/versatile-diffusion"""							)
													pipe.remove_unused_weights()
													pipe.to(__lowerCAmelCase							)
													pipe.set_progress_bar_config(disable=__lowerCAmelCase							)

													__lowerCAmelCase        =       """cyberpunk 2077"""
													__lowerCAmelCase        =       load_image(
													    """https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"""							)
													__lowerCAmelCase        =       torch.manual_seed(0							)
													__lowerCAmelCase        =       pipe(
													    prompt=__lowerCAmelCase  ,							image=__lowerCAmelCase  ,							text_to_image_strength=0.75  ,							generator=__lowerCAmelCase  ,							guidance_scale=7.5  ,							num_inference_steps=50  ,							output_type="""numpy"""  ,							).images

													__lowerCAmelCase        =       image[0, 253:256, 253:256, -1]

													assert image.shape == (1, 512, 512, 3)
													__lowerCAmelCase        =       np.array([0.0_787, 0.0_849, 0.0_826, 0.0_812, 0.0_807, 0.0_795, 0.0_818, 0.0_798, 0.0_779]							)

													assert np.abs(image_slice.flatten() - expected_slice							).max() < 1e-2


"""simple docstring"""
from __future__ import annotations
class      lowerCAmelCase_						:



							'''simple docstring'''





							def __init__(				self  ,							snake_case_							)   ->       None:
													__lowerCAmelCase        =       data
													__lowerCAmelCase        =       None
class      lowerCAmelCase_						:



							'''simple docstring'''





							def __init__(				self							)   ->       List[str]:
													__lowerCAmelCase        =       None




							def  A__		(				self  ,							snake_case_							)   ->       int:
													__lowerCAmelCase        =       Node(snake_case_							)
													__lowerCAmelCase        =       self.head
													__lowerCAmelCase        =       new_node
													return self.head.data




							def  A__		(				self							)   ->       int | None:
													__lowerCAmelCase        =       self.head
													__lowerCAmelCase        =       self.head
													if self.head:
																			while fast_pointer and fast_pointer.next:
																									__lowerCAmelCase        =       fast_pointer.next.next
																									__lowerCAmelCase        =       slow_pointer.next
																			return slow_pointer.data
													else:
																			print("""No element found."""							)
																			return None


if __name__ == "__main__":
			SCREAMING_SNAKE_CASE_			      =					LinkedList()
			for _ in range(int(input().strip())):
						SCREAMING_SNAKE_CASE_			      =					int(input().strip())
						link.push(data)
			print(link.middle_element())
