This probably should cover all kinds of test cases.
public class Program
{
public static void Main(string[] args)
{
int[] inputArray = new int[] { 1, 11, 31, 41, 61 };
int difference = 0;
for (int i = 0; i < (inputArray.Length - 1); i++)
{
int first = inputArray[i];
int second = inputArray[i + 1];
if (difference == 0)
{
difference = second - first;
}
else
{
difference = Math.Min(difference, (second - first));
}
}
WriteMissingElement(difference, inputArray);
Console.ReadKey();
}
private static void WriteMissingElement(int reqdDifference, int[] input)
{
int last = input.Last();
int nextNumber = input.First() + reqdDifference;
while (nextNumber != last)
{
if (!input.Contains(nextNumber))
{
Console.WriteLine(nextNumber);
}
nextNumber = nextNumber + reqdDifference;
}
}
}