#include <stdio.h>
#include <stdlib.h>

#define DIM 400000

void ProveraUnosa(int *x);
void Unesi(int a[], int n);

int main()
{
    int a[DIM];
    unsigned n, i, L;
    int index=-1;
    printf("Unesite broj stalaktita [1, 400000]\n");
    ProveraUnosa(&n);
    printf("Unesite visinu Perice [1, 400000]\n");
    ProveraUnosa(&L);

    Unesi(a, n);
    printf("\n");
    for (i=1; i<=n; ++i) {
        if (L>a[i]) {
            index = i+1;
            break;
        }
    }
    printf("Index = %d", index);
    return 0;
}

void ProveraUnosa(int *x)
{
    do
    {
        printf("Unos>> ", *x);
        scanf("%d", x);
        if (*x<1 || *x>DIM) printf("Doslo je do greske, pokusajte ponovo...\n");
    }
    while (*x<1 || *x>DIM);
}

void Unesi(int a[], int n)
{
    for (int i=0; i<n; i++)
    {
        printf("\nUnesite stalaktit a[%d] = ", i);
        scanf("%d", &a[i]);
    }
}