This program uses a modified version of the binary search algorithm that returns the element with the smallest index that matches the search element. It guarantees logarithmic running time.

using System;
using System.Collections.Generic;
using System.IO;

namespace ConsoleTest
{
    class Program
    {
        private static Random rnd = new Random();

        static void Main(string[] args)
        {
            int[] a = ReadInts("data.txt");

            // -or- you may want to generate random integers.
            //int[] a = GenerateInts(10000);

            Array.Sort(a);

            int i = BinarySearchSmallest(a, 800);
            Console.WriteLine(i);

            i = BinarySearchAny(a, 800);
            Console.WriteLine(i);

            Console.ReadKey();
        }

        // Return the smallest index of 'val'.
        public static int BinarySearchSmallest(T[] arr, T val) where T : IComparable
        {
            int low = 0;                // low subscript
            int high = arr.Length - 1;  // high subscript
            int middle;                 // middle subscript

            while (low <= high)
            {
                middle = (low + high) / 2;

                // Check not only arr[middle] but also the element before it.
                // If the element before arr[middle] is equal to the searched value, 
                // swith to the lower part of the array and continue binary search.
                // middle == 0 covers a case when arr[middle] is the first 
                // element in the array. In such case, it has the lowest index anyway
                // and we don't need to continue binary search.
                if (val.Equals(arr[middle]) &&
                    ((middle > 0 && !val.Equals(arr[middle - 1])) || middle == 0))
                    return middle;
                else if (val.CompareTo(arr[middle]) == -1 || val.CompareTo(arr[middle]) == 0)
                    high = middle - 1;
                else
                    low = middle + 1;
            }

            return -1; // val not found
        }

        // Return an index of any value 'val'.
        public static int BinarySearchAny(T[] arr, T val) where T : IComparable
        {
            int low = 0;                // low subscript
            int high = arr.Length - 1;  // high subscript
            int middle;                 // middle subscript

            while (low <= high)
            {
                middle = (low + high) / 2;

                if (val.Equals(arr[middle]))                // match
                    return middle;                          // found; return the index
                else if (val.CompareTo(arr[middle]) == -1)  // val < arr[middle]
                    high = middle - 1;                      // search low end of array
                else
                    low = middle + 1;
            }

            return -1; // val not found
        }

        static int[] GenerateInts(int N)
        {
            // Generate N random 3-digit numbers.
            const int MAX = 999;
            int[] a = new int[N];

            for (int i = 0; i < N; ++i)
                a[i] = rnd.Next(-MAX, MAX + 1);

            return a;
        }

        static int[] ReadInts(string filename)
        {
            List nums = new List();

            using (var reader = new StreamReader(filename))
            {
                string line;
                int num;
                while ((line = reader.ReadLine()) != null)
                {
                    if (Int32.TryParse(line, out num))
                        nums.Add(num);
                }
            }

            return nums.ToArray();
        }
    }
}