namespace InterviewSimpleSharp20220124
public static class Program
private static readonly int[] TestArray = { 1, 5, 3, 9, 12, 56, 34, 32, 12, 45, 31 };
private static int GetNearestValue(int inputValue)
int difference = Math.Abs (inputValue-TestArray [0]);
for (int i = 1; i < 11; i++)
if (Math.Abs (inputValue-TestArray [i]) < difference)
difference = Math.Abs (inputValue-TestArray [i]);
public static void Main()
int inputValue = Convert.ToInt32(Console.ReadLine());
int nearestValue = GetNearestValue(inputValue);
Console.WriteLine(nearestValue);