#include <iostream>
#include <cstdlib>

using namespace std;

// function to find the element
void find(int n, int *x, int y)
{
  for (int i = 0; i < n; i++){
      if (*(x+i)==y){
        cout << "Found at: " << i << endl;
        break;
      }
  }
}

int main(void)
{
  int N = 1<<20; // 2^20 elements

  int *x = new int[N];
  
  // initialize x array on the host
  for (int i = 0; i < N; i++) {
    *(x+i) = i;
  }

  // Run function on 1M elements on the CPU
  find(N, x, 1000000);

  // Free memory
  delete [] x;
  
  return 0;
}
