you can make your array 'a' sorted.
List<int> a = g.ToList().Select(i=>int.Parse(i)).OrderBy(i=>i);
List<int> missings=new List<int>();
int idx=0;
for(int i=0; i<a.Max(); i++) {
if(i!=a[idx])
Console.WriteLine("missing: {0}", i);
else
idx++;
}
then use this ordered list to find missings. Be aware that I haven't run that code. It may contain some syntax error. But I think the idea is clear.