#include<bits/stdc++.h>
using namespace std;
//UPPER BOUND OF ANY NUMBER IS A NUMBER WHICH IS CLOSER TO TARGET BUT GREATER NOT SMALLER
int UPPERBOUND(const vector<int>&v,int k){
    int n=v.size();
    int l=0,r=n-1,ans=n;

    while(l<=r){
        int mid=l+(r-l)/2;
        if(v[mid]>k){
            ans=mid;
            r=mid-1;
        }else{
            l=mid+1;
        }
    }
    return ans;
}
int main(){
    cout<<"Enter Size of the array-";
    int n;cin>>n;cout<<endl;
    cout<<"Enter elements in asending order"<<endl;
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    cout<<"Enter Target value- ";int t;cin>>t;cout<<endl;
    int a=UPPERBOUND(v,t);
    cout<<"Index:"<<a<<endl;
    
}