#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	int res = 1;
	vi used(n);
	for(int i = 0; i < n; i ++){
		int x;
		cin >> x;
		if(used[x]){
			res ++;
		}
		else{
			used[x] = true;
		}
	}
	cout << res;
	return 0;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),(x)))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),(x)))
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
string stin() {string s;cin>>s;return s;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
vec iota(int n){vec a(n);iota(all(a),0);return a;}
void print(){putchar(' ');}
void print(bool a){cout<<a;}
void print(int a){cout<<a;}
void print(long long a){cout<<a;}
void print(char a){cout<<a;}
void print(string &a){cout<<a;}
void print(double a){cout<<a;}
template<class T> void print(const vector<T>&);
template<class T, size_t size> void print(const array<T, size>&);
template<class T, class L> void print(const pair<T, L>& p);
template<class T, size_t size> void print(const T (&)[size]);
template<class T> void print(const vector<T>& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ cout<<" "; print(*i); } cout<<endl;}
template<class T> void print(const deque<T>& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ cout<<" "; print(*i); } }
template<class T, size_t size> void print(const array<T, size>& a){ print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ cout<<" "; print(*i); } }
template<class T, class L> void print(const pair<T, L>& p){ cout<<'(';print(p.first); cout<<","; print(p.second);cout<<')'; }
template<class T, size_t size> void print(const T (&a)[size]){ print(a[0]); for(auto i = a; ++i != end(a); ){ cout<<" "; print(*i); } }
template<class T> void print(const T& a){ cout << a; }
int out(){ putchar('\n'); return 0; }
template<class T> int out(const T& t){ print(t); putchar('\n'); return 0; }
template<class Head, class... Tail> int out(const Head& head, const Tail&... tail){ print(head); putchar(' '); out(tail...); return 0; }
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
vector<pll> factor(ll x){ vector<pll> ans; for(ll i = 2; i * i <= x; i++) if(x % i == 0){ ans.push_back({i, 1}); while((x /= i) % i == 0) ans.back().second++; } if(x != 1) ans.push_back({x, 1}); return ans; }
vector<int> divisor(int x){ vector<int> ans; for(int i=1;i*i<=x;i++)if(x%i==0){ans.pb(i);if(i*i!=x)ans.pb(x/i);} return ans;}
int popcount(ll x){return __builtin_popcountll(x);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int n){return uniform_int_distribution<int>(0, n)(rng);}
#define _GLIBCXX_DEBU
#define endl '\n'
#ifdef _MY_DEBUG
    #undef endl
    #define debug(x) cout<<#x<<": "<<x<<endl
    void err(){}
    template<class T> void err(const T& t){ print(t);  cout<<" ";}
    template<class Head, class... Tail> void err(const Head& head, const Tail&... tail){ print(head); putchar(' '); out(tail...); }
#else
    #define debug(x)
    template<class... T> void err(const T&...){}
#endif
#pragma endregion

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(15);
    int n=in();
    vec t;
    rep(i,n)t.pb(in());
    set<pii> s;
    s.emplace(0,0);
    vec mem{0};
    rep(i,n){
        auto it = s.lower_bound({t[i],0});
        if(it!=s.end() and it->first == t[i]){
            auto P = *it;
            s.erase(it);
            mem[P.se] = t[i];
            s.emplace(i+1,P.se);
        }
        else{
            mem.pb(i+1);
            s.emplace(i+1,mem.size()-1);
        }
        // for(auto e:s)print(e);cout<<endl;
    }
    cout<<mem.size()<<endl;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL

#include <algorithm>

#include <array>

#include <bitset>

#include <cassert>

#include <complex>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <vector>

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#include <unistd.h>

struct Scanner {
    int fd = -1;
    char line[(1 << 15) + 1];
    size_t st = 0, ed = 0;
    void reread() {
        memmove(line, line + st, ed - st);
        ed -= st;
        st = 0;
        ed += ::read(fd, line + ed, (1 << 15) - ed);
        line[ed] = '\0';
    }
    bool succ() {
        while (true) {
            if (st == ed) {
                reread();
                if (st == ed) return false;
            }
            while (st != ed && isspace(line[st])) st++;
            if (st != ed) break;
        }
        if (ed - st <= 50) {
            bool sep = false;
            for (size_t i = st; i < ed; i++) {
                if (isspace(line[i])) {
                    sep = true;
                    break;
                }
            }
            if (!sep) reread();
        }
        return true;
    }
    template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
    bool read_single(T& ref) {
        if (!succ()) return false;
        while (true) {
            size_t sz = 0;
            while (st + sz < ed && !isspace(line[st + sz])) sz++;
            ref.append(line + st, sz);
            st += sz;
            if (!sz || st != ed) break;
            reread();
        }
        return true;
    }
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    bool read_single(T& ref) {
        if (!succ()) return false;
        bool neg = false;
        if (line[st] == '-') {
            neg = true;
            st++;
        }
        ref = T(0);
        while (isdigit(line[st])) {
            ref = 10 * ref + (line[st++] & 0xf);
        }
        if (neg) ref = -ref;
        return true;
    }
    template <class T> bool read_single(V<T>& ref) {
        for (auto& d : ref) {
            if (!read_single(d)) return false;
        }
        return true;
    }
    void read() {}
    template <class H, class... T> void read(H& h, T&... t) {
        bool f = read_single(h);
        assert(f);
        read(t...);
    }
    Scanner(FILE* fp) : fd(fileno(fp)) {}
};

struct Printer {
  public:
    template <bool F = false> void write() {}
    template <bool F = false, class H, class... T>
    void write(const H& h, const T&... t) {
        if (F) write_single(' ');
        write_single(h);
        write<true>(t...);
    }
    template <class... T> void writeln(const T&... t) {
        write(t...);
        write_single('\n');
    }

    Printer(FILE* _fp) : fp(_fp) {}
    ~Printer() { flush(); }

  private:
    static constexpr size_t SIZE = 1 << 15;
    FILE* fp;
    char line[SIZE], small[50];
    size_t pos = 0;
    void flush() {
        fwrite(line, 1, pos, fp);
        pos = 0;
    }
    void write_single(const char& val) {
        if (pos == SIZE) flush();
        line[pos++] = val;
    }
    template <class T, enable_if_t<is_integral<T>::value, int> = 0>
    void write_single(T val) {
        if (pos > (1 << 15) - 50) flush();
        if (val == 0) {
            write_single('0');
            return;
        }
        if (val < 0) {
            write_single('-');
            val = -val; // todo min
        }
        size_t len = 0;
        while (val) {
            small[len++] = char(0x30 | (val % 10));
            val /= 10;
        }
        for (size_t i = 0; i < len; i++) {
            line[pos + i] = small[len - 1 - i];
        }
        pos += len;
    }
    void write_single(const string& s) {
        for (char c : s) write_single(c);
    }
    void write_single(const char* s) {
        size_t len = strlen(s);
        for (size_t i = 0; i < len; i++) write_single(s[i]);
    }
    template <class T> void write_single(const V<T>& val) {
        auto n = val.size();
        for (size_t i = 0; i < n; i++) {
            if (i) write_single(' ');
            write_single(val[i]);
        }
    }
};

Scanner sc = Scanner(stdin);
Printer pr = Printer(stdout);

int main() {
    int n;
    sc.read(n);
    set<int> st;
    st.insert(0);
    for (int i = 1; i <= n; i++) {
        int x;
        sc.read(x);
        if (st.count(x)) {
            st.erase(x);
        }
        st.insert(i);
    }
           ;
    pr.writeln(st.size());
    return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
bool used[222222];
int n,ans,x;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (!used[x])
		{
			ans++;
			used[i]=1;
		}
		else
		{
			used[x]=0;
			used[i]=1;
		}
	}
	printf("%d\n",ans);
	return 0;
}


// In the name of Allah.
// We're nothing and you're everything -- Imam Khomeyni.
// Ya Ali!

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 2e5 + 14;

int n;
bool mark[maxn];
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        mark[x] = 1;
    }
    cout << count(mark + 1, mark + n + 1, 0) << '\n';

}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 2e5 + 10;

int n;
bool udh[N];
int ans = 0;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i=1;i<=n;i++){
        int a;
        cin >> a;
        if (!udh[a]) ans++;
        if (i != 1) udh[i - 1] = 1;
    }
    cout << ans << el;

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 2e5 + 10;

int n;
bool udh[N];
int ans = 0;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i=1;i<=n;i++){
        int a;
        cin >> a;
        if (!udh[a]){
            ans++;
            udh[i] = 1;
        } else{
            udh[a] = 0;
            udh[i] = 1;
        }
    }
    cout << ans << el;

    return 0;
}


#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<bool> used(n, false);
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int x;
		std::cin >> x;
		if(used[x]) {
			ans++;
		} else {
			used[x] = true;
		}
	}
	std::cout << ans + 1 << '\n';
}


#include <algorithm>
#include <chrono>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll MOD = 1000000007;
const ld EPS = 1e-11;
const ll INFL = 1e16;
const int INF = 2e9 + 7;

mt19937 rnd((unsigned)chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vector<int> a(n);
    vector<bool> inc(n, false);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (inc[a[i]]) {
            ++ans;
        }
        inc[a[i]] = true;
    }

    cout << ans + 1 << "\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ";
	dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif

using uint=unsigned;
using ull=unsigned long long;

template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
	return os<<vc<t>(all(a));
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

template<class t>
void print(t x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

template<class T>
void print(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print(v[i],i==int(v.size())-1?suc:2);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

//#define CAPITAL
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<"\n";
	#else
	cout<<"Yes"<<"\n";
	#endif
	if(ex)exit(0);
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<"\n";
	#else
	cout<<"No"<<"\n";
	#endif
	if(ex)exit(0);
}
void possible(bool ex=true){
	#ifdef CAPITAL
	cout<<"POSSIBLE"<<"\n";
	#else
	cout<<"Possible"<<"\n";
	#endif
	if(ex)exit(0);
}
void impossible(bool ex=true){
	#ifdef CAPITAL
	cout<<"IMPOSSIBLE"<<"\n";
	#else
	cout<<"Impossible"<<"\n";
	#endif
	if(ex)exit(0);
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
ll mask(int i){
	return (ll(1)<<i)-1;
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
	#ifdef LOCAL
	static mt19937_64 gen;
	#else
	static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	return uniform_int_distribution<ll>(l, r)(gen);
}

template<class t>
void myshuffle(vc<t>&a){
	rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}

template<class t>
int lwb(const vc<t>&v,const t&a){
	return lower_bound(all(v),a)-v.bg;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);

	int n;cin>>n;
	vi u(n+1,0);
	int ans=1;
	u[0]=1;
	rng(i,1,n+1){
		int t;cin>>t;
		if(u[t]){
			u[t]=0;
		}else{
			ans++;
		}
		u[i]=1;
	}
	print(ans);
}


#include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ";
	dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif

using uint=unsigned;
using ull=unsigned long long;

template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
	return os<<vc<t>(all(a));
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

template<class t>
void print(t x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

template<class T>
void print(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print(v[i],i==int(v.size())-1?suc:2);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

//#define CAPITAL
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<"\n";
	#else
	cout<<"Yes"<<"\n";
	#endif
	if(ex)exit(0);
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<"\n";
	#else
	cout<<"No"<<"\n";
	#endif
	if(ex)exit(0);
}
void possible(bool ex=true){
	#ifdef CAPITAL
	cout<<"POSSIBLE"<<"\n";
	#else
	cout<<"Possible"<<"\n";
	#endif
	if(ex)exit(0);
}
void impossible(bool ex=true){
	#ifdef CAPITAL
	cout<<"IMPOSSIBLE"<<"\n";
	#else
	cout<<"Impossible"<<"\n";
	#endif
	if(ex)exit(0);
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
ll mask(int i){
	return (ll(1)<<i)-1;
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
	#ifdef LOCAL
	static mt19937_64 gen;
	#else
	static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	return uniform_int_distribution<ll>(l, r)(gen);
}

template<class t>
void myshuffle(vc<t>&a){
	rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}

template<class t>
int lwb(const vc<t>&v,const t&a){
	return lower_bound(all(v),a)-v.bg;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);

	int n;cin>>n;
	vi u(n+1,0);
	int ans=0;
	rng(i,1,n+1){
		int t;cin>>t;
		if(u[t]){
			u[t]=0;
		}else{
			ans++;
			u[i]++;
		}
	}
	print(ans);
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 1000000007
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 300003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int cnt=1,n,x;
bool ada[mx];
int main(){
	cin>>n;
	ada[0]=true;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(ada[x]){
			ada[x]=false;
		}
		else{
			cnt++;
		}
		ada[i]=true;
	}
	cout<<cnt;
}


#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define _file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long
#define ld long double
#define sp setprecision
#define pb push_back
#define F first
#define S second
#define mk make_pair
#define pii pair < int , int >
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;
const int maxn = 4e4 + 100;
const ll inf = 1e18;

//Main CODE :/\

int a[maxn] , b[maxn];
map < int , int > mp;
int main(){
	ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	int n , m;
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		b[i] = a[i];
		mp[a[i]] = i + 1;
	}
	sort(b , b + n);
	for (int i = 0; i < m; i++){
		int t , s , pos , bd , x = 1;
		cin >> t >> s;
		t--;
		pos = upper_bound(b , b + n , a[t]) - b - 1;
		int prv = -1 , z;
		while (2 > 1){
			if (x == 1){
				bd = upper_bound(b , b + n , b[pos] + s) - b - 1;
				z = -b[pos] + b[bd];
			}
			else{
				bd = lower_bound(b , b + n , b[pos] - s) - b;
				z = -b[bd] + b[pos];
			}
			s -= z;
			if (bd == prv && bd == pos)
				break;
			if (bd == prv)
				s %= 2 * z;
			prv = pos;
			pos = bd;
			x ^= 1;
		}
		cout << mp[b[pos]] << "\n";
	}

	return 0;
}


/**
 *    author:  Atreus
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 2e5 + 10;
// 0 is right direction
// 1 is left direction
int n, pos[maxn];
pair<int, int> x[maxn];

int dis(int fi, int se){
	return abs(x[fi].first - x[se].first);
}

int nex(int idx, int len, bool direction){
	if (direction == 0){
		int lo = idx, hi = n + 1;
		while (hi - lo > 1){
			int mid = (lo + hi) >> 1;
			if (dis(idx, mid) <= len)
				lo = mid;
			else
				hi = mid;
		}
		return lo;
	}
	int lo = 0, hi = idx;
	while (hi - lo > 1){
		int mid = (lo + hi) >> 1;
		if (dis(idx, mid) <= len)
			hi = mid;
		else
			lo = mid;
	}
	return hi;
}

int findans(int idx, int len, bool direction){
	int next_one = nex(idx, len, direction);
	if (next_one == idx)
		return x[idx].second;
	int Distance = dis(idx, next_one);
	if ((len / Distance) & 1)
		return findans(next_one, len % Distance, direction ^ 1);
	return findans(idx, len % Distance, direction);
}

int main(){
	ios_base::sync_with_stdio(false);
	int m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		cin >> x[i].first;
		x[i].second = i;
	}
	sort(x + 1, x + n + 1);
	for (int i = 1; i <= n; i++)
		pos[x[i].second] = i;
	for (int i = 0; i < m; i++){
		int idx, l;
		cin >> idx >> l;
		idx = pos[idx];
		int next_one = nex(idx, l, 0);
		cout << findans(next_one, l - dis(idx, next_one), 1) << '\n';
	}
}


#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template <typename T, typename V>
void ndarray(vector<T>& vec, const V& val, int len) { vec.assign(len, val); }
template <typename T, typename V, typename... Args> void ndarray(vector<T>& vec, const V& val, int len, Args... args) { vec.resize(len), for_each(begin(vec), end(vec), [&](T& v) { ndarray(v, val, args...); }); }
template <typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template <typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
template <typename T> vector<T> srtunq(vector<T> vec) { sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; }
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; }
#if __cplusplus >= 201703L
template <typename... T> istream &operator>>(istream &is, tuple<T...> &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; }
template <typename... T> ostream &operator<<(ostream &os, const tuple<T...> &tpl) { std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os; }
#endif
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T, typename TH> ostream &operator<<(ostream &os, const unordered_set<T, TH> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <typename TK, typename TV, typename TH> ostream &operator<<(ostream &os, const unordered_map<TK, TV, TH> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
#ifdef HITONANODE_LOCAL
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl
#else
#define dbg(x) {}
#endif

int main()
{
    int N, M;
    cin >> N >> M;
    if (N == 1) {
        REP(_, M) puts("1");
        return 0;
    }
    vector<int> X(N);
    cin >> X;
    map<int, int> x2ans;
    REP(i, N) x2ans[X[i]] = i + 1;

    vector<int> xs = X;

    xs = srtunq(xs);
    auto xsinv = xs;
    for (auto &x : xsinv) x *= -1;
    reverse(ALL(xsinv));

    vector<int> ret;
    while (M--) {
        int a, l;
        cin >> a >> l;
        int now = X[a - 1];
        while (true) {
            dbg(plint(now, l));
            auto itr = prev(upper_bound(xs.begin(), xs.end(), now + l));
            int d = *itr - now;
            int k = now + d;
            l -= d;
            auto itr2 = prev(upper_bound(xsinv.begin(), xsinv.end(), -k + l));
            int nxt = -(*itr2);
            l -= k - nxt;
            if (now == nxt and now == k) {
                ret.emplace_back(x2ans[now]);
                break;
            } else if (now == nxt) {
                l %= (k - now) * 2;
            }
            now = nxt;
        }
    }
    for (auto x : ret) cout << x << '\n';
}


#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)(x).size()
#define pb          push_back
#define eb          emplace_back
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, m;
    cin >> n >> m;
    map<int, int> idx;
    vt<int> a(n), pegs(n);
    rep(i, n) {
        cin >> a[i];
        idx[a[i]] = i + 1;
        pegs[i] = a[i];
    }
    sort(all(pegs));

    while (m--) {
        int x, len;
        cin >> x >> len;
        x = distance(pegs.begin(), lower_bound(all(pegs), a[--x]));

        for (;;) {
            int hit = distance(pegs.begin(),
                upper_bound(pegs.begin() + x, pegs.end(),
                            pegs[x] + len) - 1);
            if (hit != x) {
                int len2 = len - (pegs[hit] - pegs[x]);
                int hit2 = distance(pegs.begin(),
                    lower_bound(pegs.begin(), pegs.begin() + hit + 1,
                                pegs[hit] - len2));
                if (hit2 != x) {
                    x = hit2;
                    len = len2 - (pegs[hit] - pegs[hit2]);
                } else {
                    int gap = pegs[hit] - pegs[x];
                    int cnt = len / gap;
                    if (cnt & 1) x = hit;
                    len %= gap;
                }
            } else {
                hit = distance(pegs.begin(),
                    lower_bound(pegs.begin(), pegs.begin() + x + 1,
                                pegs[x] - len));
                if (hit == x) break;

                len -= pegs[x] - pegs[hit];
                x = hit;
            }
        }

        cout << idx[pegs[x]] << '\n';
    }
}


/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 200010;

ll n, m;
ll X[maxn];
ll lst[maxn];
ll id1[maxn], id2[maxn];

bool x_cmp(ll a, ll b) {
    return X[a] < X[b];
}

void MAIN() {

    cin >> n >> m;
    fori (i, n) cin >> X[i];
    iota(id1, id1 + n, 0);
    sort(id1, id1 + n, x_cmp);
    sort(X, X + n);
    fori (i, n) id2[id1[i]] = i;
    lst[0] = -1;
    fori (q, m) {
        ll p, L; cin >> p >> L;
        p = id2[p - 1];
        ll j = 1;
        ll i = 1;
        lst[i++] = p;
        while (true) {
            ll nxt;
            if (j) nxt = upper_bound(X, X + n, X[p] + L) - X - 1;
            else   nxt = lower_bound(X, X + n, X[p] - L) - X;
            if (nxt == lst[i - 1]) {
                cout << id1[nxt] + 1 << '\n';
                break;
            }
            ll ln = abs(X[p] - X[nxt]);
            j ^= 1, L -= ln;
            if (nxt == lst[i - 2]) {
                L %= ln * 2;
            }
            lst[i++] = nxt;
            p = nxt;
        }
    }

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
2 1
5 7
1 9

4 4
1 5 7 15
1 4
2 15
3 16
1 28
    )";
    MAIN();
    return 0;
}


/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 200010;

ll n, m;
ll X[maxn];
ll lst[maxn];
ll id1[maxn], id2[maxn];

bool x_cmp(ll a, ll b) {
    return X[a] < X[b];
}

void MAIN() {

    cin >> n >> m;
    fori (i, n) cin >> X[i];
    iota(id1, id1 + n, 0);
    sort(id1, id1 + n, x_cmp);
    fori (i, n) id2[id1[i]] = i;
    lst[0] = -1;
    fori (q, m) {
        ll p, L; cin >> p >> L;
        p = id2[p - 1];
        ll j = 1;
        ll i = 1;
        lst[i++] = p;
        while (true) {
            ll nxt;
            if (j) nxt = upper_bound(X, X + n, X[p] + L) - X - 1;
            else   nxt = lower_bound(X, X + n, X[p] - L) - X;
            if (nxt == lst[i - 1]) {
                cout << id1[nxt] + 1 << '\n';
                break;
            }
            ll ln = abs(X[p] - X[nxt]);
            j ^= 1, L -= ln;
            if (nxt == lst[i - 2]) {
                L %= ln * 2;
            }
            lst[i++] = nxt;
            p = nxt;
        }
    }

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
2 1
5 7
1 9

4 4
1 5 7 15
1 4
2 15
3 16
1 28
    )";
    MAIN();
    return 0;
}


/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 200010;

ll n, m;
ll X[maxn];
ll lst[maxn];

void MAIN() {

    cin >> n >> m;
    fori (i, n) cin >> X[i];
    lst[0] = -1;
    fori (q, m) {
        ll p, L; cin >> p >> L; --p;
        ll j = 1;
        ll i = 1;
        lst[i++] = p;
        while (true) {
            ll nxt;
            if (j) nxt = upper_bound(X, X + n, X[p] + L) - X - 1;
            else   nxt = lower_bound(X, X + n, X[p] - L) - X;
            if (nxt == lst[i - 1]) {
                cout << nxt + 1 << '\n';
                break;
            }
            ll ln = abs(X[p] - X[nxt]);
            j ^= 1, L -= ln;
            if (nxt == lst[i - 2]) {
                L %= ln * 2;
            }
            lst[i++] = nxt;
            p = nxt;
        }
    }

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
2 1
5 7
1 9

4 4
1 5 7 15
1 4
2 15
3 16
1 28
    )";
    MAIN();
    return 0;
}


/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 200010;

ll n, m;
ll X[maxn];
ll lst[maxn];
ll id1[maxn], id2[maxn];

bool x_cmp(ll a, ll b) {
    return X[a] < X[b];
}

void MAIN() {

    cin >> n >> m;
    fori (i, n) cin >> X[i];
    iota(id1, id1 + n, 0);
    sort(id1, id1 + n, x_cmp);
    sort(X, X + n);
    fori (i, n) id2[id1[i]] = i;
    lst[0] = -1;
    fori (q, m) {
        ll p, L; cin >> p >> L;
        p = id2[p - 1];
        ll j = 1;
        ll i = 1;
        lst[i++] = p;
        while (true) {
            ll nxt;
            if (j) nxt = upper_bound(X, X + n, X[p] + L) - X - 1;
            else   nxt = lower_bound(X, X + n, X[p] - L) - X;
            if (nxt == lst[i - 1] && nxt == lst[i - 2]) {
                cout << id1[nxt] + 1 << '\n';
                break;
            }
            ll ln = abs(X[p] - X[nxt]);
            j ^= 1, L -= ln;
            if (nxt == lst[i - 2]) {
                L %= ln * 2;
            }
            lst[i++] = nxt;
            p = nxt;
        }
    }

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
2 1
5 7
1 9

4 4
1 5 7 15
1 4
2 15
3 16
1 28
    )";
    MAIN();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll  long
#define mod 1000000007

int ara[200000],posi[200000],rev[200000];
vector<int>my;
vector<pii>vc;

int seardane(int pos,int kto)
{
    int lo=pos+1,high=my.size()-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]>kto)
        {
            high=mid-1;
            continue;
        }
        ans=mid;
        lo=mid+1;
    }
    return  ans;

}
int searbame(int pos,int kto)
{
    int lo=0,high=pos-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]<kto)
        {
            lo=mid+1;
            continue;
        }
        ans=mid;
        high=mid-1;
    }
    return  ans;

}
int func(int index,int len,int ki)
{

    if(ki==1)
    {
         int f=my[index];
        int get=seardane(index,f+len);
       if(get==-1)
       {
           get=searbame(index,f-len);
           if(get==-1)return index;
           int ln=my[index]-my[get];
           int v=len%ln;
           int w=len/ln;

           if(w%2==0)
           {
               return func(index,v,-1);
           }
           return func(get,v,1);
       }
        int ln=my[get]-my[index];
           int v=len%ln;
           int w=len/ln;
           if(w%2==0)return func(index,v,1);
           return func(get,v,-1);
    }
    int f=my[index];
    int get=searbame(index,f-len);
    if(get==-1)
    {
        get=seardane(index,f+len);
        if(get==-1)return index;
        int ln=my[get]-my[index];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,-1);
    }
     int ln=my[index]-my[get];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,-1);
        }
        return func(get,v,1);
}
int main()
{
    int i,j,k,l,m,n,q;
    scanf("%d%d",&n,&q);
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&l);
       vc.pb(mp(l,i));
   }
   sort(vc.begin(),vc.end());
   for(int i=0;i<vc.size();i++){
    posi[vc[i].second]=i;
    rev[i]=vc[i].second;
    my.pb(vc[i].first);
   }
   while(q--)
   {
       scanf("%d%d",&l,&k);
       int ac=func(posi[l],k,1);
       printf("%d\n",rev[ac]);
   }

}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll  long
#define mod 1000000007

int ara[200000],posi[200005],rev[200005];
vector<int>my;
vector<pii>vc;

int seardane(int pos,int kto)
{
    int lo=pos+1,high=my.size()-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]>kto)
        {
            high=mid-1;
            continue;
        }
        ans=mid;
        lo=mid+1;
    }
    return  ans;

}
int searbame(int pos,int kto)
{
    int lo=0,high=pos-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]<kto)
        {
            lo=mid+1;
            continue;
        }
        ans=mid;
        high=mid-1;
    }
    return  ans;

}
int func(int index,int len,int ki)
{

    if(ki==1)
    {
         int f=my[index];
        int get=seardane(index,f+len);
       if(get==-1)
       {
           get=searbame(index,f-len);
           if(get==-1)return index;
           int ln=my[index]-my[get];
           int v=len%ln;
           int w=len/ln;

           if(w%2==0)
           {
               return func(index,v,1);
           }
           return func(get,v,1);
       }
        int ln=my[get]-my[index];
           int v=len%ln;
           int w=len/ln;
           if(w%2==0)return func(index,v,1);
           return func(get,v,1);
    }
    assert(1/0);
    int f=my[index];
    int get=searbame(index,f-len);
    if(get==-1)
    {
        get=seardane(index,f+len);
        if(get==-1)return index;
        int ln=my[get]-my[index];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,1);
    }
     int ln=my[index]-my[get];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,1);
}
int main()
{
    int i,j,k,l,m,n,q;
    scanf("%d%d",&n,&q);
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&l);
       vc.pb(mp(l,i));
   }
   sort(vc.begin(),vc.end());
   for(int i=0;i<vc.size();i++){
    posi[vc[i].second]=i;
    rev[i]=vc[i].second;
    my.pb(vc[i].first);
   }
   while(q--)
   {
       scanf("%d%d",&l,&k);
       int ac=func(posi[l],k,1);
       printf("%d\n",rev[ac]);
   }

}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll  long
#define mod 1000000007

int ara[200000],posi[200000],rev[200000];
vector<int>my;
vector<pii>vc;

int seardane(int pos,int kto)
{
    int lo=pos+1,high=my.size()-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]>kto)
        {
            high=mid-1;
            continue;
        }
        ans=mid;
        lo=mid+1;
    }
    return  ans;

}
int searbame(int pos,int kto)
{
    int lo=0,high=pos-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]<kto)
        {
            lo=mid+1;
            continue;
        }
        ans=mid;
        high=mid-1;
    }
    return  ans;

}
int func(int index,int len,int ki)
{

    if(ki==1)
    {
         int f=my[index];
        int get=seardane(index,f+len);
       if(get==-1)
       {
           get=searbame(index,f-len);
           if(get==-1)return index;
           int ln=my[index]-my[get];
           int v=len%ln;
           int w=len/ln;

           if(w%2==0)
           {
               return func(index,v,1);
           }
           return func(get,v,1);
       }
        int ln=my[get]-my[index];
           int v=len%ln;
           int w=len/ln;
           if(w%2==0)return func(index,v,1);
           return func(get,v,1);
    }
    assert(1/0);
    int f=my[index];
    int get=searbame(index,f-len);
    if(get==-1)
    {
        get=seardane(index,f+len);
        if(get==-1)return index;
        int ln=my[get]-my[index];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,1);
    }
     int ln=my[index]-my[get];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,1);
}
int main()
{
    int i,j,k,l,m,n,q;
    scanf("%d%d",&n,&q);
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&l);
       vc.pb(mp(l,i));
   }
   sort(vc.begin(),vc.end());
   for(int i=0;i<vc.size();i++){
    posi[vc[i].second]=i;
    rev[i]=vc[i].second;
    my.pb(vc[i].first);
   }
   while(q--)
   {
       scanf("%d%d",&l,&k);
       int ac=func(posi[l],k,1);
       printf("%d\n",rev[ac]);
   }

}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll  long
#define mod 1000000007

int ara[200000],posi[200000],rev[200000];
vector<int>my;
vector<pii>vc;

int seardane(int pos,int kto)
{
    int lo=pos+1,high=my.size()-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]>kto)
        {
            high=mid-1;
            continue;
        }
        ans=mid;
        lo=mid+1;
    }
    return  ans;

}
int searbame(int pos,int kto)
{
    int lo=0,high=pos-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]<kto)
        {
            lo=mid+1;
            continue;
        }
        ans=mid;
        high=mid-1;
    }
    return  ans;

}
int func(int index,int len,int ki)
{

    if(ki==1)
    {
         int f=my[index];
        int get=seardane(index,f+len);
       if(get==-1)
       {
           get=searbame(index,f-len);
           if(get==-1)return index;
           int ln=my[index]-my[get];
           int v=len%ln;
           int w=len/ln;

           if(w%2==0)
           {
               return func(index,v,1);
           }
           return func(get,v,1);
       }
        int ln=my[get]-my[index];
           int v=len%ln;
           int w=len/ln;
           if(w%2==0)return func(index,v,1);
           return func(get,v,1);
    }
    int f=my[index];
    int get=searbame(index,f-len);
    if(get==-1)
    {
        get=seardane(index,f+len);
        if(get==-1)return index;
        int ln=my[get]-my[index];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,1);
    }
     int ln=my[index]-my[get];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,1);
}
int main()
{
    int i,j,k,l,m,n,q;
    scanf("%d%d",&n,&q);
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&l);
       vc.pb(mp(l,i));
   }
   sort(vc.begin(),vc.end());
   for(int i=0;i<vc.size();i++){
    posi[vc[i].second]=i;
    rev[i]=vc[i].second;
    my.pb(vc[i].first);
   }
   while(q--)
   {
       scanf("%d%d",&l,&k);
       int ac=func(posi[l],k,1);
       printf("%d\n",rev[ac]);
   }

}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll  long
#define mod 1000000007

int ara[200000],posi[200005],rev[200005];
vector<int>my;
vector<pii>vc;

int seardane(int pos,int kto)
{
    int lo=pos+1,high=my.size()-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]>kto)
        {
            high=mid-1;
            continue;
        }
        ans=mid;
        lo=mid+1;
    }
    return  ans;

}
int searbame(int pos,int kto)
{
    int lo=0,high=pos-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]<kto)
        {
            lo=mid+1;
            continue;
        }
        ans=mid;
        high=mid-1;
    }
    return  ans;

}
int func(int index,int len,int ki)
{

    if(ki==1)
    {
        int f=my[index];
        int get=seardane(index,f+len);
        if(get==-1)
        {
            get=searbame(index,f-len);
            if(get==-1)return index;
            int ln=my[index]-my[get];
            int ps=seardane(get,my[get]+(len-len));
            if(ps==index)
            {
                int v=len%ln;
                int w=len/ln;
                if(w%2==0)
                {
                    return func(index,v,-1);
                }
                return func(get,v,1);
            }
            return func(get,len-ln,1);
        }
        int ln=my[get]-my[index];
        int ps=searbame(get,my[get]-(len-ln));
        if(ps==index)
        {
            int v=len%ln;
            int w=len/ln;
            if(w%2==0)return func(index,v,1);
            return func(get,v,-1);
        }
        return func(get,len-ln,-1);
    }
    int f=my[index];
    int get=searbame(index,f-len);
    if(get==-1)
    {
        get=seardane(index,f+len);
        if(get==-1)return index;
        int ln=my[get]-my[index];
        int ps=searbame(get,my[get]-(len-ln));
        if(ps==index)
        {
            int v=len%ln;
            int w=len/ln;
            if(w%2==0)return func(index,v,1);
            return func(get,v,-1);
        }
        return func(get,len-ln,-1);
    }
    int ln=my[index]-my[get];
    int ps=seardane(get,my[get]+(len-len));
    if(ps==index)
    {
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
            return func(index,v,-1);
        }
        return func(get,v,1);
    }
    return func(get,len-ln,1);
}
int main()
{
    int i,j,k,l,m,n,q;
    scanf("%d%d",&n,&q);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&l);
        vc.pb(mp(l,i));
    }
    sort(vc.begin(),vc.end());
    for(int i=0; i<vc.size(); i++)
    {
        posi[vc[i].second]=i;
        rev[i]=vc[i].second;
        my.pb(vc[i].first);
    }
    while(q--)
    {
        scanf("%d%d",&l,&k);
        int ac=func(posi[l],k,1);
        printf("%d\n",rev[ac]);
        //cout<<my[ac]<<endl;
    }

}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll  long
#define mod 1000000007

int ara[200000],posi[200000],rev[200000];
vector<int>my;
vector<pii>vc;

int seardane(int pos,int kto)
{
    int lo=pos+1,high=my.size()-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]>kto)
        {
            high=mid-1;
            continue;
        }
        ans=mid;
        lo=mid+1;
    }
    return  ans;

}
int searbame(int pos,int kto)
{
    int lo=0,high=pos-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]<kto)
        {
            lo=mid+1;
            continue;
        }
        ans=mid;
        high=mid-1;
    }
    return  ans;

}
int func(int index,int len,int ki)
{

    if(ki==1)
    {
         int f=my[index];
        int get=seardane(index,f+len);
       if(get==-1)
       {
           get=searbame(index,f-len);
           if(get==-1)return index;
           int ln=my[index]-my[get];
           int v=len%ln;
           int w=len/ln;

           if(w%2==0)
           {
               return func(index,v,-1);
           }
           return func(get,v,1);
       }
        int ln=my[get]-my[index];
           int v=len%ln;
           int w=len/ln;
           if(w%2==0)return func(index,v,1);
           return func(get,v,-1);
    }
    int f=my[index];
    int get=searbame(index,f-len);
    if(get==-1)
    {
        get=seardane(index,f+len);
        if(get==-1)return index;
        int ln=my[get]-my[index];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,-1);
    }
     int ln=my[index]-my[get];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,-1);
        }
        return func(get,v,1);
}
int main()
{
    int i,j,k,l,m,n,q;
    scanf("%d%d",&n,&q);
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&l);
       vc.pb(mp(l,i));
   }
   sort(vc.begin(),vc.end());
   for(int i=0;i<vc.size();i++){
    posi[vc[i].second]=i;
    rev[i]=vc[i].second;
    my.pb(vc[i].first);
   }
   while(q--)
   {
       scanf("%d%d",&l,&k);
       int ac=func(posi[l],k,1);
       cout<<rev[ac]<<endl;
   }

}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll  long
#define mod 1000000007

int ara[200000],posi[200005],rev[200005];
vector<int>my;
vector<pii>vc;

int seardane(int pos,int kto)
{
    int lo=pos+1,high=my.size()-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]>kto)
        {
            high=mid-1;
            continue;
        }
        ans=mid;
        lo=mid+1;
    }
    return  ans;

}
int searbame(int pos,int kto)
{
    int lo=0,high=pos-1,ans=-1,mid;
    while(lo<=high)
    {
        mid=(lo+high)>>1;
        if(my[mid]<kto)
        {
            lo=mid+1;
            continue;
        }
        ans=mid;
        high=mid-1;
    }
    return  ans;

}
int func(int index,int len,int ki)
{

    if(ki==1)
    {
         int f=my[index];
        int get=seardane(index,f+len);
       if(get==-1)
       {
           get=searbame(index,f-len);
           if(get==-1)return index;
           int ln=my[index]-my[get];
           int v=len%ln;
           int w=len/ln;

           if(w%2==0)
           {
               return func(index,v,-1);
           }
           return func(get,v,1);
       }
        int ln=my[get]-my[index];
           int v=len%ln;
           int w=len/ln;
           if(w%2==0)return func(index,v,1);
           return func(get,v,-1);
    }
   // assert(1/0);
    int f=my[index];
    int get=searbame(index,f-len);
    if(get==-1)
    {
        get=seardane(index,f+len);
        if(get==-1)return index;
        int ln=my[get]-my[index];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,1);
        }
        return func(get,v,-1);
    }
     int ln=my[index]-my[get];
        int v=len%ln;
        int w=len/ln;
        if(w%2==0)
        {
           return func(index,v,-1);
        }
        return func(get,v,1);
}
int main()
{
    int i,j,k,l,m,n,q;
    scanf("%d%d",&n,&q);
   for(int i=1;i<=n;i++)
   {
       scanf("%d",&l);
       vc.pb(mp(l,i));
   }
   sort(vc.begin(),vc.end());
   for(int i=0;i<vc.size();i++){
    posi[vc[i].second]=i;
    rev[i]=vc[i].second;
    my.pb(vc[i].first);
   }
   while(q--)
   {
       scanf("%d%d",&l,&k);
       int ac=func(posi[l],k,1);
       printf("%d\n",rev[ac]);
   }

}


#include <bits\stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m; cin>>n>>m;
	vector<ll> x(n);
	for (int i=0;i<n;i++) cin>>x[i];
	map<ll,ll> func[2];
	for (int i=0;i<n;i++) func[1][x[i]]=i;
	for (int i=0;i<n;i++) func[0][i]=x[i];
	sort(x.begin(),x.end());
	while (m--) {
		int a; ll l;
		cin>>a>>l;
		a-=1;
		a=lower_bound(x.begin(),x.end(),func[0][a])-x.begin();
		int ans=0;
		while (1) {
			auto ub=upper_bound(x.begin(),x.end(),x[a]+l)-1;
			auto lb=lower_bound(x.begin(),x.end(),*ub-(l-(*ub-x[a])));
			if (lb==ub) {
				ans=ub-x.begin();
				break;
			}
			if (lb-x.begin()==a) {
				cout<<"hello"<<endl;
				l%=2LL*(*ub-x[a]);
			} else {
				l-=(*ub-x[a]+*ub-*lb);
				a=lb-x.begin();
			}
		}
		cout<<func[1][x[ans]]+1<<endl;
	}
}


#include <bits\stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
int main() {
	int n, m; cin>>n>>m;
	vector<ll> x(n);
	for (int i=0;i<n;i++) cin>>x[i];
	sort(x.begin(),x.end());
	while (m--) {
		int a; ll l;
		cin>>a>>l;
		a-=1;
		int ans=0;
		while (1) {
			auto ub=upper_bound(x.begin(),x.end(),x[a]+l)-1;
			if (*ub-x[a]==0) {
				ans=a;
				break;
			}
			if (*ub-x[a]==l) {
				ans=ub-x.begin();
				break;
			}
			auto lb=lower_bound(x.begin(),x.end(),*ub-(l-(*ub-x[a])));
			if (lb-x.begin()==a) {
				l%=2*(*ub-x[a]);
			} else {
				l-=(*ub-x[a]+*ub-*lb);
				a=lb-x.begin();
			}
		}
		cout<<ans+1<<endl;
	}
}


#include <bits\stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m; cin>>n>>m;
	vector<ll> x(n);
	for (int i=0;i<n;i++) cin>>x[i];
	map<ll,ll> func[2];
	for (int i=0;i<n;i++) func[1][x[i]]=i;
	for (int i=0;i<n;i++) func[0][i]=x[i];
	sort(x.begin(),x.end());
	while (m--) {
		int a; ll l;
		cin>>a>>l;
		a-=1;
		a=lower_bound(x.begin(),x.end(),func[0][a])-x.begin();
		int ans=0;
		while (1) {
			auto ub=upper_bound(x.begin(),x.end(),x[a]+l)-1;
			auto lb=lower_bound(x.begin(),x.end(),*ub-(l-(*ub-x[a])));
			if (lb==ub) {
				ans=ub-x.begin();
				break;
			}
			if (lb-x.begin()==a) {
//				cout<<"hello"<<endl;
				l%=2LL*(*ub-x[a]);
			} else {
				l-=(*ub-x[a]+*ub-*lb);
				a=lb-x.begin();
			}
		}
		cout<<func[1][x[ans]]+1<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int n, q; cin >> n >> q;
  vector<int> A(n); for (int i = 0; i < n; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  auto near = [=](int i) {
    return i == 0 ? A[1] - A[0] : i == n - 1 ?
           A[n - 1] - A[n - 2] : min(A[i] - A[i - 1], A[i + 1] - A[i]);
  };
  auto next = [=](int i, int l) {
    return upper_bound(A.begin() + i, A.end(), A[i] + l) - A.begin() - 1;
  };
  auto prev = [=](int i, int l) {
    return lower_bound(A.begin(), A.begin() + i, A[i] - l) - A.begin();
  };

  while (q--) {
    int i, l; cin >> i >> l;
    --i;
    {
      int ni = next(i, l);
      l -= A[ni] - A[i];
      i = ni;
    }
    bool dir = false;
    while (near(i) <= l) {
      if (dir) {
        int j = next(i, l);
        if (i < j) {
          l %= 2ll * (A[j] - A[i]);
          if (A[j] - A[i] <= l) dir = false, l -= A[j] - A[i], i = j;
        }
        else dir = false;
      }
      else {
        int j = prev(i, l);
        if (j < i) {
          l %= 2ll * (A[i] - A[j]);
          if (A[i] - A[j] <= l) dir = true, l -= A[i] - A[j], i = j;
        }
        else dir = true;
      }
    }
    cout << i + 1 << '\n';
  }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int n, q; cin >> n >> q;
  vector<int> A(n), rk(n), iv(n); for (int i = 0; i < n; ++i) cin >> A[i];
  iota(rk.begin(), rk.end(), 0);
  iv = rk;
  sort(rk.begin(), rk.end(), [&](int i, int j) { return A[i] < A[j]; });
  sort(iv.begin(), iv.end(), [&](int i, int j) { return A[i] < A[j]; });
  sort(A.begin(), A.end());
  auto near = [=](int i) {
    return i == 0 ? A[1] - A[0] : i == n - 1 ?
           A[n - 1] - A[n - 2] : min(A[i] - A[i - 1], A[i + 1] - A[i]);
  };
  auto next = [=](int i, int l) {
    return upper_bound(A.begin() + i, A.end(), A[i] + l) - A.begin() - 1;
  };
  auto prev = [=](int i, int l) {
    return lower_bound(A.begin(), A.begin() + i + 1, A[i] - l) - A.begin();
  };

  while (q--) {
    int i, l; cin >> i >> l;
    --i;
    i = iv[i];
    for (int _ = 0; _ < 10; ++_) {
      int ni = next(i, l);
      l -= A[ni] - A[i];
      i = ni;
      ni = prev(i, l);
      l -= A[i] - A[ni];
      i = ni;
    }
    bool dir = true;
    while (near(i) <= l) {
      if (dir) {
        int j = next(i, l);
        if (i < j) {
          l %= 2ll * (A[j] - A[i]);
          if (A[j] - A[i] <= l) dir = false, l -= A[j] - A[i], i = j;
        }
        else dir = false;
      }
      else {
        int j = prev(i, l);
        if (j < i) {
          l %= 2ll * (A[i] - A[j]);
          if (A[i] - A[j] <= l) dir = true, l -= A[i] - A[j], i = j;
        }
        else dir = true;
      }
    }
    cout << rk[i] + 1 << '\n';
  }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int n, q; cin >> n >> q;
  vector<int> A(n), rk(n), iv(n); for (int i = 0; i < n; ++i) cin >> A[i];
  iota(rk.begin(), rk.end(), 0);
  iv = rk;
  sort(rk.begin(), rk.end(), [&](int i, int j) { return A[i] < A[j]; });
  sort(iv.begin(), iv.end(), [&](int i, int j) { return A[i] < A[j]; });
  sort(A.begin(), A.end());
  auto near = [=](int i) {
    return i == 0 ? A[1] - A[0] : i == n - 1 ?
           A[n - 1] - A[n - 2] : min(A[i] - A[i - 1], A[i + 1] - A[i]);
  };
  auto next = [=](int i, int l) {
    return upper_bound(A.begin() + i, A.end(), A[i] + l) - A.begin() - 1;
  };
  auto prev = [=](int i, int l) {
    return lower_bound(A.begin(), A.begin() + i + 1, A[i] - l) - A.begin();
  };

  while (q--) {
    int i, l; cin >> i >> l;
    --i;
    i = iv[i];
    for (int _ = 0; _ < 10; ++_) {
      int ni = next(i, l);
      l -= A[ni] - A[i];
      i = ni;
      ni = prev(i, l);
      l -= A[i] - A[ni];
      i = ni;
    }
    bool dir = true;
    while (near(i) <= l) {
      assert(0);
      if (dir) {
        int j = next(i, l);
        if (i < j) {
          l %= 2ll * (A[j] - A[i]);
          if (A[j] - A[i] <= l) dir = false, l -= A[j] - A[i], i = j;
        }
        else dir = false;
      }
      else {
        int j = prev(i, l);
        if (j < i) {
          l %= 2ll * (A[i] - A[j]);
          if (A[i] - A[j] <= l) dir = true, l -= A[i] - A[j], i = j;
        }
        else dir = true;
      }
    }
    cout << rk[i] + 1 << '\n';
  }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int n, q; cin >> n >> q;
  vector<int> A(n), rk(n), iv(n); for (int i = 0; i < n; ++i) cin >> A[i];
  iota(rk.begin(), rk.end(), 0);
  iv = rk;
  sort(rk.begin(), rk.end(), [&](int i, int j) { return A[i] < A[j]; });
  sort(iv.begin(), iv.end(), [&](int i, int j) { return rk[i] < rk[j]; });
  sort(A.begin(), A.end());
  auto near = [=](int i) {
    return i == 0 ? A[1] - A[0] : i == n - 1 ?
           A[n - 1] - A[n - 2] : min(A[i] - A[i - 1], A[i + 1] - A[i]);
  };
  auto next = [=](int i, int l) {
    return upper_bound(A.begin() + i, A.end(), A[i] + l) - A.begin() - 1;
  };
  auto prev = [=](int i, int l) {
    return lower_bound(A.begin(), A.begin() + i + 1, A[i] - l) - A.begin();
  };

  while (q--) {
    int i, l; cin >> i >> l;
    --i;
    i = iv[i];
    {
      int ni = next(i, l);
      l -= A[ni] - A[i];
      i = ni;
      ni = prev(i, l);
      l -= A[i] - A[ni];
      i = ni;
    }
    bool dir = true;
    while (near(i) <= l) {
      if (dir) {
        int j = next(i, l);
        if (i < j) {
          l %= 2ll * (A[j] - A[i]);
          if (A[j] - A[i] <= l) dir = false, l -= A[j] - A[i], i = j;
        }
        else dir = false;
      }
      else {
        int j = prev(i, l);
        if (j < i) {
          l %= 2ll * (A[i] - A[j]);
          if (A[i] - A[j] <= l) dir = true, l -= A[i] - A[j], i = j;
        }
        else dir = true;
      }
    }
    cout << rk[i] + 1 << '\n';
  }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int n, q; cin >> n >> q;
  vector<int> A(n), rk(n), iv(n); for (int i = 0; i < n; ++i) cin >> A[i];
  iota(rk.begin(), rk.end(), 0);
  iv = rk;
  sort(rk.begin(), rk.end(), [&](int i, int j) { return A[i] < A[j]; });
  sort(iv.begin(), iv.end(), [&](int i, int j) { return rk[i] < rk[j]; });
  sort(A.begin(), A.end());
  auto near = [=](int i) {
    return i == 0 ? A[1] - A[0] : i == n - 1 ?
           A[n - 1] - A[n - 2] : min(A[i] - A[i - 1], A[i + 1] - A[i]);
  };
  auto next = [=](int i, int l) {
    return upper_bound(A.begin() + i, A.end(), A[i] + l) - A.begin() - 1;
  };
  auto prev = [=](int i, int l) {
    return lower_bound(A.begin(), A.begin() + i + 1, A[i] - l) - A.begin();
  };

  while (q--) {
    int i, l; cin >> i >> l;
    if (n == 1) {
      cout << 1 << '\n'; continue;
    }
    --i;
    i = iv[i];
    {
      int ni = next(i, l);
      l -= A[ni] - A[i];
      i = ni;
      ni = prev(i, l);
      l -= A[i] - A[ni];
      i = ni;
    }
    bool dir = true;
    while (near(i) <= l) {
      if (dir) {
        int j = next(i, l);
        if (i < j) {
          l %= 2ll * (A[j] - A[i]);
          if (A[j] - A[i] <= l) dir = false, l -= A[j] - A[i], i = j;
        }
        else dir = false;
      }
      else {
        int j = prev(i, l);
        if (j < i) {
          l %= 2ll * (A[i] - A[j]);
          if (A[i] - A[j] <= l) dir = true, l -= A[i] - A[j], i = j;
        }
        else dir = true;
      }
    }
    cout << rk[i] + 1 << '\n';
  }
}


#include<bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int n, q; cin >> n >> q;
  vector<int> A(n); for (int i = 0; i < n; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  auto near = [=](int i) {
    return i == 0 ? A[1] - A[0] : i == n - 1 ?
           A[n - 1] - A[n - 2] : min(A[i] - A[i - 1], A[i + 1] - A[i]);
  };
  auto next = [=](int i, int l) {
    return upper_bound(A.begin() + i, A.end(), A[i] + l) - A.begin() - 1;
  };
  auto prev = [=](int i, int l) {
    return lower_bound(A.begin(), A.begin() + i, A[i] - l) - A.begin();
  };

  while (q--) {
    int i, l; cin >> i >> l;
    --i;
    for (int _ = 0; _ < 10; ++_) {
      int ni = next(i, l);
      l -= A[ni] - A[i];
      i = ni;
      ni = prev(i, l);
      l -= A[i] - A[ni];
      i = ni;
    }
    bool dir = true;
    while (near(i) <= l) {
      if (dir) {
        int j = next(i, l);
        if (i < j) {
          l %= 2ll * (A[j] - A[i]);
          if (A[j] - A[i] <= l) dir = false, l -= A[j] - A[i], i = j;
        }
        else dir = false;
      }
      else {
        int j = prev(i, l);
        if (j < i) {
          l %= 2ll * (A[i] - A[j]);
          if (A[i] - A[j] <= l) dir = true, l -= A[i] - A[j], i = j;
        }
        else dir = true;
      }
    }
    cout << i + 1 << '\n';
  }
}


#include <iostream>
#include <set>

using namespace std;

const int MAX_N = 2e5 + 5;

int pos [MAX_N];
set<pair<int, int>> pegset;

int last_upto (int x) {
  return prev(pegset.upper_bound(make_pair(x, MAX_N)))->second;
}

int first_atleast (int x) {
  return pegset.lower_bound(make_pair(x, -1))->second;
}

struct state {
  int peg, len, side; // 0 if forward, 1 if backward
};

state naive_nxt (state s) {
  state ans;
  if (s.side == 0) {
    ans.peg = last_upto(pos[s.peg] + s.len);
  } else {
    ans.peg = first_atleast(pos[s.peg] - s.len);
  }

  ans.len = s.len - abs(pos[ans.peg] - pos[s.peg]);
  ans.side = !s.side;
  return ans;
}

state quick_nxt (state s) {
  state nxt = naive_nxt(s);
  state nxt_nxt = naive_nxt(nxt);
  if (nxt.peg == s.peg) {
    return nxt;
  }

  if (nxt_nxt.peg == s.peg) {
    int ldiff = s.len - nxt_nxt.len;
    if (ldiff != 0) {
      nxt_nxt.len %= ldiff;
    }
    return naive_nxt(nxt_nxt);
  } else {
    return nxt_nxt;
  }
}

bool accepting (state s) {
  state nxt = naive_nxt(s);
  state nxt_nxt = naive_nxt(nxt);

  return s.peg == nxt.peg && nxt.peg == nxt_nxt.peg;
}

void solve () {
  state cur;
  cin >> cur.peg >> cur.len;
  cur.side = 0;

  while (true) {
    cur = quick_nxt(cur);
    if (accepting(cur)) {
      cout << cur.peg << '\n';
      return;
    }
  }
}

int main () {
  int pegc, queryc;
  cin >> pegc >> queryc;

  for (int i = 1; i <= pegc; i++) {
    cin >> pos[i];
    pegset.insert(make_pair(pos[i], i));
  }

  for (int i = 0; i < queryc; i++) {
    solve();
  }
}


#include <iostream>
#include <set>

using namespace std;

const int MAX_N = 2e5 + 5;

int pos [MAX_N];
set<pair<int, int>> pegset;

int last_upto (int x) {
  return prev(pegset.upper_bound(make_pair(x, MAX_N)))->second;
}

int first_atleast (int x) {
  return pegset.lower_bound(make_pair(x, -1))->second;
}

struct state {
  int peg, len, side; // 0 if forward, 1 if backward
};

state naive_nxt (state s) {
  state ans;
  if (s.side == 0) {
    ans.peg = last_upto(pos[s.peg] + s.len);
  } else {
    ans.peg = first_atleast(pos[s.peg] - s.len);
  }

  ans.len = s.len - abs(pos[ans.peg] - pos[s.peg]);
  ans.side = !s.side;
  return ans;
}

state quick_nxt (state s) {
  state nxt = naive_nxt(s);
  state nxt_nxt = naive_nxt(nxt);
  if (nxt.peg == s.peg) {
    return nxt;
  }

  if (nxt_nxt.peg == s.peg) {
    int ldiff = s.len - nxt_nxt.len;
    if (ldiff != 0) {
      nxt_nxt.len %= ldiff;
    }
    return naive_nxt(nxt_nxt);
  } else {
    return nxt_nxt;
  }
}

void solve () {
  state cur;
  cin >> cur.peg >> cur.len;
  cur.side = 0;

  while (true) {
    state nxt = quick_nxt(cur);
    if (cur.peg == nxt.peg) {
      cout << cur.peg << '\n';
      return;
    }

    cur = nxt;
  }
}

int main () {
  int pegc, queryc;
  cin >> pegc >> queryc;

  for (int i = 1; i <= pegc; i++) {
    cin >> pos[i];
    pegset.insert(make_pair(pos[i], i));
  }

  for (int i = 0; i < queryc; i++) {
    solve();
  }
}


#include <iostream>
#include <set>

using namespace std;

const int MAX_N = 2e5 + 5;

int pos [MAX_N];
set<pair<int, int>> pegset;

int last_upto (int x) {
  return prev(pegset.upper_bound(make_pair(x, MAX_N)))->second;
}

int first_atleast (int x) {
  return pegset.lower_bound(make_pair(x, -1))->second;
}

struct state {
  int peg, len, side; // 0 if forward, 1 if backward
};

state naive_nxt (state s) {
  state ans;
  if (s.side == 0) {
    ans.peg = last_upto(pos[s.peg] + s.len);
  } else {
    ans.peg = first_atleast(pos[s.peg] - s.len);
  }

  ans.len = s.len - abs(pos[ans.peg] - pos[s.peg]);
  ans.side = !s.side;
  return ans;
}

state quick_nxt (state s) {
  state nxt = naive_nxt(s);
  state nxt_nxt = naive_nxt(nxt);
  if (nxt.peg == s.peg) {
    return nxt;
  }

  if (nxt_nxt.peg == s.peg) {
    int ldiff = s.len - nxt_nxt.len;
    if (ldiff != 0) {
      nxt_nxt.len %= ldiff;
    }
    return nxt_nxt;
  } else {
    return nxt_nxt;
  }
}

void solve () {
  state cur;
  cin >> cur.peg >> cur.len;
  cur.side = 0;

  while (true) {
    state nxt = quick_nxt(cur);
    if (cur.peg == nxt.peg) {
      cout << cur.peg << '\n';
      return;
    }

    cur = nxt;
  }
}

int main () {
  int pegc, queryc;
  cin >> pegc >> queryc;

  for (int i = 1; i <= pegc; i++) {
    cin >> pos[i];
    pegset.insert(make_pair(pos[i], i));
  }

  for (int i = 0; i < queryc; i++) {
    solve();
  }
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define gcd __gcd
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define fi first
#define se second
#define pqueue priority_queue
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << '(' << p.fi << ", " << p.se << ')'; }

template<typename T>
void printv(const T& v) { for(auto i : v) cerr << i << ' '; cerr << '\n'; }

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

//Returns no. of values x for which ceil(n / x) == y (y must be > 1).
inline ll CC(ll n, ll y) { return iceil(n, y-1) - iceil(n, y); }

//Returns no. of values x for which floor(n / x) == y
inline ll FF(ll n, ll y) { return n / y - n / (y+1); }

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

#define N 200005
#define int ll
// #define trace(...) 42

int n, m, x[N];
pii ar[N];

main()
{
    #ifndef ONLINE_JUDGE
        freopen("/home/tarun/Desktop/input.txt", "r", stdin);
     // freopen("/home/tarun/Desktop/output.txt", "w", stdout);
    #endif
    sync;
    clock_t clk = clock();
    cerr << "I will return...\n";

    cin >> n >> m;
    rep(i, 0, n) {
        cin >> x[i];
        ar[i] = {x[i], i};
    }

    sort(ar, ar + n);
    // rep(i, 0, n) trace(i, ar[i]);

    while(m--) {
        int i, l; cin >> i >> l; --i;
        i = lower_bound(ar, ar + n, pii{x[i], 0}) - ar;

        bool turn = 1; //0 for left; 1 for right
        bool first = 1; //Is it the first turn

        // trace(i, l, turn);

        while(1) {
            // static int cnt = 50; assert(cnt--);
            if(i == 0) turn = 1;
            if(i == n-1) turn = 0;

            int j;
            if(turn) {
                j = lower_bound(ar, ar + n, pii{ar[i].fi + l + 1, 0}) - ar - 1;
            }
            else {
                j = lower_bound(ar, ar + n, pii{ar[i].fi - l, 0}) - ar;
            }
            // trace(i, j, l, turn);

            if(i == j) {
                cout << ar[i].se + 1 << '\n';
                break;
            }

            int len = abs(ar[i].fi - ar[j].fi);

            if(first || 2 * len >= l) {
                l -= len;
                i = j;
                first = 0;
                turn = !turn;
            }
            else {
                if(l / len % 2) {
                    i = j;
                    turn = !turn;
                }
                l %= len;
            }
            // trace(i, j, l, len, turn);
        }
    }

    cerr << "...don't you ever hang your head.\n";
    cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define gcd __gcd
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define fi first
#define se second
#define pqueue priority_queue
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << '(' << p.fi << ", " << p.se << ')'; }

template<typename T>
void printv(const T& v) { for(auto i : v) cerr << i << ' '; cerr << '\n'; }

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

//Returns no. of values x for which ceil(n / x) == y (y must be > 1).
inline ll CC(ll n, ll y) { return iceil(n, y-1) - iceil(n, y); }

//Returns no. of values x for which floor(n / x) == y
inline ll FF(ll n, ll y) { return n / y - n / (y+1); }

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

#define N 200005
#define int ll
// #define trace(...) 42

int n, m, x[N];
pii ar[N];

main()
{
    #ifndef ONLINE_JUDGE
        freopen("/home/tarun/Desktop/input.txt", "r", stdin);
     freopen("/home/tarun/Desktop/output.txt", "w", stdout);
    #endif
    sync;
    clock_t clk = clock();
    cerr << "I will return...\n";

    cin >> n >> m;
    rep(i, 0, n) {
        cin >> x[i];
        ar[i] = {x[i], i};
    }

    sort(ar, ar + n);

    while(m--) {
        int i, l; cin >> i >> l; --i;
        i = lower_bound(ar, ar + n, pii{x[i], 0}) - ar;

        bool turn = 1; //0 for left; 1 for right
        bool first = 1; //Is it the first turn

        //To avoid handling special cases, perform the first 2 moves beforehand
        int j = lower_bound(ar, ar + n, pii{ar[i].fi + l + 1, 0}) - ar - 1;
        l -= ar[j].fi - ar[i].fi;
        i = j;

        j = lower_bound(ar, ar + n, pii{ar[i].fi - l, 0}) - ar;
        l -= ar[i].fi - ar[j].fi;
        i = j;

        while(1) {
            int j;
            if(turn) {
                j = lower_bound(ar, ar + n, pii{ar[i].fi + l + 1, 0}) - ar - 1;
            }
            else {
                j = lower_bound(ar, ar + n, pii{ar[i].fi - l, 0}) - ar;
            }

            if(i == j) {
                cout << ar[i].se + 1 << '\n';
                break;
            }

            int len = abs(ar[i].fi - ar[j].fi);
            assert(l >= len);

            if(first || 2 * len >= l) {
                l -= len;
                i = j;
                first = 0;
                turn = !turn;
            }
            else {
                if(l / len % 2) {
                    i = j;
                    turn = !turn;
                }
                l %= len;
            }
        }
    }

    cerr << "...don't you ever hang your head.\n";
    cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define gcd __gcd
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define fi first
#define se second
#define pqueue priority_queue
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << '(' << p.fi << ", " << p.se << ')'; }

template<typename T>
void printv(const T& v) { for(auto i : v) cerr << i << ' '; cerr << '\n'; }

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

//Returns no. of values x for which ceil(n / x) == y (y must be > 1).
inline ll CC(ll n, ll y) { return iceil(n, y-1) - iceil(n, y); }

//Returns no. of values x for which floor(n / x) == y
inline ll FF(ll n, ll y) { return n / y - n / (y+1); }

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }

#define N 200005
#define int ll
// #define trace(...) 42

int n, m, x[N];
pii ar[N];

main()
{
    #ifndef ONLINE_JUDGE
        freopen("/home/tarun/Desktop/input.txt", "r", stdin);
     // freopen("/home/tarun/Desktop/output.txt", "w", stdout);
    #endif
    sync;
    clock_t clk = clock();
    cerr << "I will return...\n";

    cin >> n >> m;
    rep(i, 0, n) {
        cin >> x[i];
        ar[i] = {x[i], i};
    }

    sort(ar, ar + n);

    while(m--) {
        int i, l; cin >> i >> l; --i;
        i = lower_bound(ar, ar + n, pii{x[i], 0}) - ar;

        bool turn = 1; //0 for left; 1 for right
        bool first = 1; //Is it the first turn

        // trace(i, l, turn);

        while(1) {
            // static int cnt = 50; assert(cnt--);
            if(i == 0) turn = 1;
            if(i == n-1) turn = 0;

            int j;
            if(turn) {
                j = lower_bound(ar, ar + n, pii{ar[i].fi + l + 1, 0}) - ar - 1;
            }
            else {
                j = lower_bound(ar, ar + n, pii{ar[i].fi - l, 0}) - ar;
            }

            if(!l || i == j) {
                cout << ar[i].se + 1 << '\n';
                break;
            }

            int len = abs(x[i] - x[j]);

            if(first || 2 * len >= l) {
                l -= len;
                i = j;
                first = 0;
                turn = !turn;
            }
            else {
                if(l / len % 2) {
                    i = j;
                    turn = !turn;
                }
                l %= len;
            }
            // trace(i, l, turn);
        }
    }

    cerr << "...don't you ever hang your head.\n";
    cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment