#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int s=0,b=0;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);s+=a[i];
}

for(int i=0;i<n;i++)
{
	b+=a[i];
	if(b>=(s/2))
	{
		printf("%d\n",i+1);
		return 0;
	}

}

 }


#include<iostream>
#include<algorithm>
using namespace std;
int n,a[200001],s,sum;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],s+=a[i];
    for(int i=1;i<=n;i++)
    {
        sum+=a[i];
        if(sum>=(s+1)/2){cout<<i<<endl;return 0;}
    }
    return 0;
}


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

const int M=200005;
int a[M],n,s;

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i],s+=a[i];
	s=(s+1)/2;//s是应做的题数，因为直接/2是向下取整，所以先加一
	int sum=0;//sum是当前的做题数
	for (int i=1;i<=n;i++)
	{
		sum+=a[i];
		if (sum>=s)
		{
			cout<<i;
			return 0;
        //如果大于，只要输出，然后直接return 0即可
		}
	}
}


#include<cstdio>
#include<algorithm>
using namespace std;
int m;
int sum=0,ans;
int f[1000000];
int main()
{
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&f[i]);
		sum+=f[i];
		f[i]+=f[i-1];
	}
	sum/=2;
	for(int i=1;i<=m;i++){
		if(f[i]>=sum){
			printf("%d",i);
			return 0;
		}
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
using namespace std;
int n,s,b[111111];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&s),b[i]=b[i-1]+s;
	for(int i=1;i<=n;i++){
		if(b[i]>=double(b[n]/2)){
			printf("%d",i);
			return 0;
		}
 	}
}


#include<iostream>
using namespace std;
int m=0,n,a[200001],k=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        m+=a[i];
    }
    m=m/2+1;
    for(int i=1;i<=n;i++)
    {
        k+=a[i];
        if(k>=m)
        cout<<i;
    }
    return 0;
}


#include<iostream>
using namespace std;
int a[200005];
int main()
{
	int n;
	cin>>n;
	double ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		ans=ans+a[i];
	}
	ans=ans/2;
	int p=0;
	int place;
	while(ans>0)
	{
		ans=ans-a[++p];
	}
	cout<<p;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[10001],i,s=0,s2=0,av;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        s+=a[i];
    }
    av=(s/2)+(s%2)
    for(i=0;i<n;i++)
    {
        s2+=a[i];
        if(s2>=av)
        {
            printf("%d",i+1);
            break;
        }
    }
    return 0;
}


#include <iostream>
using namespace std;
int a[100001];
int sum=0,tot=0;
int main(){
	int i,j,k,n;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sum=(sum+1)/2;
	for(i=1;i<=n;i++){
		tot+=a[i];
		if(tot>=sum){
			cout<<i<<endl;
			return 0;
		}
	}
}


#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<assert.h>
#include<set>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<bitset>
#include<stack>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define per(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
using namespace std;
typedef long long LL;
typedef double db;
const int MAXN=100000;
long long num[MAXN+10];
int main()
{
	long long n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
		sum+=num[i];
	}
	long long sum1=0;
	for(int i=1;i<=n;i++){
		sum1+=num[i];
		if(sum1*2>=sum){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[200010],n,s=0,k=0;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),s+=a[i];
    if(s%2) s=s/2+1;
    else s/=2;
    while(s>0) s-=a[++k];
    printf("%d",k);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[200005],i,s=0,s2=0,av;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        s+=a[i];
    }
    av=(s/2)+(s%2);
    for(i=0;i<n;i++)
    {
        s2+=a[i];
        if(s2>=av)
        {
            printf("%d",i+1);
            break;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,x,s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		s+=x;
		if(s>=n)
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}


#include<iostream>
using namespace std;
int main() {
	int n,i,s1=0,s2=0,ans=0;
	cin>>n;
	int a[n];
	for (i=0; i<n; i++) {
		cin>>a[i];
		s1+=a[i];
	}
	if (s1%2) s1++;
	for (i=0; i<n; i++) {
		if (s2>=s1/2)
			break;
		ans++;
		s2+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[200001];
int main()
{
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	int ssuumm=0;
	for(int i=1;i<=n;i++)
	{
		ssuumm+=a[i];
		if(ssuumm>=(sum+1)/2)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int a,b[200000],ans=0;
double sum=0,sum1=0;
int main()
{
    cin>>a;
    for(int i=0;i<a;i++)
    {
        cin>>b[i];
        sum=sum+b[i];

    }
    sum=sum/2;
    for(int i=0;i<a;i++)
    {
        sum1=sum1+b[i];
        if(sum1>=sum)
       {
		 cout<<ans+1;;
		 return 0;
       }
       if(sum1<sum)
       ans++;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[200005],m=0,b=0,d=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b+=a[i];
	}
	b=b/2+1;
	for(int i=0;i<n;i++)
	{
		d+=a[i];
		if(d<b||d==b)
		  m++;
		else
		  break;
	}
	cout<<m;
	return 0;
}


#include<cstdio>
using namespace std;
int n,a[200001],s,t;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        s+=a[i];
    }
    s=s+1>>1;
    for(int i=1;i<=n;++i){
        t+=a[i];
        if(t>=s){
            printf("%d",i);
            return 0;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sum,answer;
    sum=0;int i;cin>>n;int a[n+1];
    for(i=0;i<n;i++)cin>>a[i],sum+=a[i];
    for(i=0;i<n;i++)
    {
        answer+=a[i];
        if(answer>=sum/2.0)break;
    }
    answer=1+i;
    cout<<answer<<endl;
    return 0;
}


#include <cstdio>
using namespace std;
int main()
{
	int n,sum=0,result=0;
	scanf("%d",&n);
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		result+=a[i];
		if(result>=sum/2)
		{
			printf("%d",i);
			break;
		}
	}
	return 0;
}


#include <iostream>
using namespace std;
int main(){
	int a[200001],n,half=0,day=0;
	cin>>n;
	for(int i=1;i<=n;i++) {cin>>a[i];half+=a[i];}
	if(half%2) half=half/2+1;
	else half/=2;
	while(half>0) half-=a[++day];
	cout<<day<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	double sum=0,sum1=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i],sum+=a[i];
	for(int i=0;i<n;i++)
	{
		sum1+=a[i];
		if(sum1>=(sum/2))
		{
			cout<<i+1<<endl;
			return 0;
		}
	}

	return 0;
 }


#include<iostream>
using namespace std;
int m=0,n,a[200001],k=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        m+=a[i];
    }
    if(m%2)
    m=m/2+1;
    else
    m/=2;
    for(int i=1;i<=n;i++)
    {
        k+=a[i];
        if(k>=m)
        cout<<i;
    }
    return 0;
}


#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	int s=0;
	for(int i=0;i<n;i++){
		s+=a[i];
		if(s>=sum/2+sun%2){
			cout<<i+1;
			return 0;
		}
	}
}


#include <iostream>
using namespace std;

int arr[200005];

int main()
{
	int n, sum = 0, sum2 = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> arr[i];
		sum += arr[i];
	}
	for(int i = 1; i <= n; i++)
	{
		sum2 += arr[i];
		if(sum2 >= sum / 2)
		{
			cout << i << endl;
			exit(0);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0)

int main ()
{
	IO;
	int n, sum = 0;
	multiset<int> se;
	map<int, int> mp;
	cin >> n;
	for(int i = 0;i < n; i++){
		int x;
		cin >> x;
		sum += x;
		se.insert(sum);
		mp[sum] = i + 1;
	}
	int temp;
	temp = ceil(sum / 2);
	int ans = *se.lower_bound(temp);
	int res = mp[ans];
	cout << res << '\n';
	return 0;
 }


#include<bits/stdc++.h>
using namespace std;
int n,a[200001];
int ans,t;
double sum;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){cin>>a[i];sum+=a[i];}
    sum/=2;
    while(t<sum){ans++;t+=a[ans];}
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n,sum=0,sum1=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i],sum+=a[i];
	for(int i=0;i<n;i++)
	{
		sum1+=a[i];
		if(sum1>=(sum/2))
		{
			cout<<i+1;
			return 0;
		}
	}

	return 0;
 }


#include <iostream>
using namespace std;

int arr[200005];

int main()
{
	int n, sum = 0, sum2 = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> arr[i];
		sum += arr[i];
	}
	for(int i = 1; i <= n; i++)
	{
		sum2 += arr[i];
		if(sum % 2 == 0)
		{
            if(sum2 >= sum1 / 2)
            {
    			cout << i << endl;
    			exit(0);
            }
		}
        else
        {
            if(sum2 >= sum1 / 2 + 1)
            {
                cout << i << endl;
    			exit(0);
            }
        }
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[200005],k,sum;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&k);
        a[i]=a[i-1]+k;
        sum+=k;
    }
    if(sum%2==0) sum/=2;
    else sum=sum/2+1;
    for(int i=1;i<=n;i++){
        if(a[i]>=sum){
            cout<<i;
            break;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long hyf[200010];
int main()
{
	long long n,m,k,i,j,t=0,t1=0,t2=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
    	cin>>hyf[i];
    	t+=hyf[i];
	}
    for(i=1;i<=n;i++)
    {
    	t1+=hyf[i];
    	if(t1>t/2&&t%2==1)
    	{
    		cout<<i;
    		return 0;
		}
		else if(t1>=t/2&&t%2==0)
		{
			cout<<i;
			return 0;
		}
	}
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int a[100001];
int main()
{
	int n;
	int tot1=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		tot1+=a[i];
	}
	int tot2=0;
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--)
	{
		tot2+=a[i];
		if(tot2>=tot1*1.0/2)
		{
			cout<<n-i+1<<endl;
			break;
		}
	}
	return 0;
}


#include<cstdio>
int s,ans,a[200005],n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]),s+=a[i];
    int i=0;
    for(;i<n;i++){ans+=a[i];if(ans>=s*1.0/2)break;}
    printf("%d",i+1);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define For(i,x,y)for(i=x;i<=y;i++)
int a[200005];
int read()
{
    int A;
    bool K;
    char C;
    C=A=K=0;
    while(C<'0'||C>'9')K|=C=='-',C=getchar();
    while(C>'/'&&C<':')A=(A<<3)+(A<<1)+(C^48),C=getchar();
    return(K?-A:A);
}
int main()
{
    int n,i;
    n=read();
    For(i,1,n)a[i]=read(),a[i]+=a[i-1];
    For(i,1,n)
    if(a[i]>=(a[n]+1)>>1)break;
    cout<<i;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
using namespace std;
int n,s,b[111111];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&s),b[i]=b[i-1]+s;
	for(int i=1;i<=n;i++){
		if(b[i]>=b[n]/2){
			printf("%d",i);
			return 0;
		}
 	}
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=200005;
int n,a[MAXN];
int main(){
    int sum=0;
    scanf ("%d",&n);
    for (int i=1;i<=n;i++){
        scanf ("%d",&a[i]);
        sum+=a[i];
    }
    int now=0;
    for (int i=1;i<=n;i++){
        now+=a[i];
        if (now>=sum/2){
            printf ("%d",i);
            break;
        }
    }
    return 0;
}


#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<assert.h>
#include<set>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<bitset>
#include<stack>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define per(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
using namespace std;
typedef long long LL;
typedef double db;
const int MAXN=10000000;
int num[MAXN+10];
int main()
{
	int n;
	LL sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
		sum+=num[i];
	}
	LL sum1=0;
	for(int i=1;i<=n;i++){
		sum1+=num[i];
		if(sum1*2>=sum){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a[10028];
	int n,s=0,o=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	    cin>>a[i];
	    s+=a[i];
	}
	s/=2;
	for(int i=1;i<=n;i++)
	{
		if(o>=s)
		{
			cout<<i-1;
	        return 0;
		}
		else
		{
			o+=a[i];
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int n,a[20001],s,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],s+=a[i];
	for(int i=1;i<=n;i++)
	{
		ans+=a[i];
		if(ans>=s/2)
		{
			cout<<i;
			return 0;
		}
	}
}


#include<iostream>
using namespace std;
int main()
{
    int a[200001],n,half=0,day=0;
    cin>>n;
    for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		half+=a[i];
	}
    if(half%2)
    {
    	half=half/2+1;
	}
    else
    {
    	half/=2;
	}
    while(half>0)
    {
    	half-=a[++day];
	}
    cout<<day<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[200005]={};
	int n;
	cin>>n;
	long long sum=0,sol=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		sol+=a[i];
		if(2*sol>=sum)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


#include<cstdio>
int s,ans,a[200005],n;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]),s+=a[i];
    int i=0;
    for(;i<n;i++){ans+=a[i];if(ans>=s*1.0/2)break;}
    printf("%d",i+1);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int p,n,i;
	double s=0,s1=0;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(i=0;i<n;i++)
	{
		s+=a[i];
	}
	for(i=0;;i++)
	{
		s1+=a[i];
		if(s1>=s/2)
		{
			p=i;
			break;
		}
	}
	if(n==1)
	cout<<"1";
	else
	cout<<p+1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int s=0,s1=0,i,n;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(i=0;i<n;i++)
	{
		s+=a[i];
	}
	for(i=0;;i++)
	{
		s1+=a[i];
		if(s1>=s)
		{
			p=a[i];
			break;
		}
	}
	if(n==1)
	cout<<"1";
	else
	cout<<p+1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int p,s=0,s1=0,i,n;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(i=0;i<n;i++)
	{
		s+=a[i];
	}
	for(i=0;;i++)
	{
		s1+=a[i];
		if(s1>=s)
		{
			p=a[i];
			break;
		}
	}
	if(n==1)
	cout<<"1";
	else
	cout<<p+1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int p,s=0,s1=0,i,n;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(i=0;i<n;i++)
	{
		s+=a[i];
	}
	for(i=0;;i++)
	{
		s1+=a[i];
		if(s1>=s)
		{
			p=a[i];
			break;
		}
	}
	cout<<p+1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int p,s=0,s1=0,i,n;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(i=0;i<n;i++)
	{
		s+=a[i];
	}
	for(i=0;;i++)
	{
		s1+=a[i];
		if(s1>=s/2)
		{
			p=a[i];
			break;
		}
	}
	if(n==1)
	cout<<"1";
	else
	cout<<p+1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int p,s=0,s1=0,i,n;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(i=0;i<n;i++)
	{
		s+=a[i];
	}
	for(i=0;;i++)
	{
		s1+=a[i];
		if(s1>=s/2)
		{
			p=i;
			break;
		}
	}
	if(n==1)
	cout<<"1";
	else
	cout<<p+1;
	return 0;
}


#include <bits/stdc++.h>

#ifndef _WIN32
  #define getchar getchar_unlocked
  #define putchar putchar_unlocked
#endif

#define rep(i, N) for (int i = 0; i < N; ++i)

using namespace std;

typedef unsigned u32;
typedef long long i64;
typedef unsigned long long u64;

int get_int() {
  int n = 0, sign = 0; char c;
  while ((c = getchar()) < '-');
  if (c == '-') sign = 1;
  else n = c - '0';
  while ((c = getchar()) >= '0') n = n * 10 + c - '0';
  return sign ? -n : n;
}

struct IO {
#ifndef __APPLE__
  #define fread fread_unlocked
  #define fwrite fwrite_unlocked
#endif
  static const int SIZE = 1 << 14;
  ~IO() { if (oi) flush(); }
  void flush() { fwrite(out, 1, oi, stdout), oi = 0; }
  char gchar() {
    if (ii == SIZE) {
      ii = 0;
      fread(in, 1, SIZE, stdin);
    }
    return in[ii++];
  }
  void pchar(const char& c) {
    out[oi++] = c;
    if (oi == SIZE) flush();
  }
  int get_int() {
    int ret = 0, sign = 0; char c;
    while ((c = gchar()) < '-');
    if (c == '-') sign = 1;
    else ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return sign ? -ret : ret;
  }
  u32 get_u32() {
    u32 ret; char c;
    while ((c = gchar()) < '0');
    ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return ret;
  }
  template <typename T>
  void put(T n) {
    if (n < 0) n = -n, pchar('-');
    static char stac[20]; int i = 0;
    do { stac[i++] = n % 10 + '0', n /= 10; } while (n);
    while (i) pchar(stac[--i]);
  }
  void pstr(const char* s) { while (*s) pchar(*(s++)); }
  char in[SIZE], out[SIZE];
  int ii = SIZE, oi = 0;
} io;

void solve() {
  int N = io.get_u32();
  vector<int> A(N);
  int sum = 0;
  rep(i, N) A[i] = io.get_u32(), sum += A[i];
  int pref = 0;
  rep(i, N) if ((pref += A[i]) >= sum / 2) {
    printf("%d\n", i + 1);
    return;
  }
}

int main() {
  clock_t beg = clock();
  solve();
  clock_t end = clock();
  fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);
  return 0;
}


#include <bits/stdc++.h>

#ifndef _WIN32
  #define getchar getchar_unlocked
  #define putchar putchar_unlocked
#endif

#define rep(i, N) for (int i = 0; i < N; ++i)

using namespace std;

typedef unsigned u32;
typedef long long i64;
typedef unsigned long long u64;

int get_int() {
  int n = 0, sign = 0; char c;
  while ((c = getchar()) < '-');
  if (c == '-') sign = 1;
  else n = c - '0';
  while ((c = getchar()) >= '0') n = n * 10 + c - '0';
  return sign ? -n : n;
}

struct IO {
#if !(__APPLE__ || _WIN32)
  #define fread fread_unlocked
  #define fwrite fwrite_unlocked
#endif
  static const int SIZE = 1 << 14;
  ~IO() { if (oi) flush(); }
  void flush() { fwrite(out, 1, oi, stdout), oi = 0; }
  char gchar() {
    if (ii == SIZE) {
      ii = 0;
      fread(in, 1, SIZE, stdin);
    }
    return in[ii++];
  }
  void pchar(const char& c) {
    out[oi++] = c;
    if (oi == SIZE) flush();
  }
  int get_int() {
    int ret = 0, sign = 0; char c;
    while ((c = gchar()) < '-');
    if (c == '-') sign = 1;
    else ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return sign ? -ret : ret;
  }
  u32 get_u32() {
    u32 ret; char c;
    while ((c = gchar()) < '0');
    ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return ret;
  }
  template <typename T>
  void put(T n) {
    if (n < 0) n = -n, pchar('-');
    static char stac[20]; int i = 0;
    do { stac[i++] = n % 10 + '0', n /= 10; } while (n);
    while (i) pchar(stac[--i]);
  }
  void pstr(const char* s) { while (*s) pchar(*(s++)); }
  char in[SIZE], out[SIZE];
  int ii = SIZE, oi = 0;
} io;

void solve() {
  int N = io.get_u32();
  vector<int> A(N);
  int sum = 0;
  rep(i, N) A[i] = io.get_u32(), sum += A[i];
  int pref = 0;
  rep(i, N) if ((pref += A[i]) * 2 >= sum) {
    printf("%d\n", i + 1);
    return;
  }
}

int main() {
  clock_t beg = clock();
  solve();
  clock_t end = clock();
  fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);
  return 0;
}


#include <bits/stdc++.h>

#ifndef _WIN32
  #define getchar getchar_unlocked
  #define putchar putchar_unlocked
#endif

#define rep(i, N) for (int i = 0; i < N; ++i)

using namespace std;

typedef unsigned u32;
typedef long long i64;
typedef unsigned long long u64;

int get_int() {
  int n = 0, sign = 0; char c;
  while ((c = getchar()) < '-');
  if (c == '-') sign = 1;
  else n = c - '0';
  while ((c = getchar()) >= '0') n = n * 10 + c - '0';
  return sign ? -n : n;
}

struct IO {
#ifdef _WIN32
  #define fread _fread_nolock
  #define fwrite _fwrite_nolock
#elif !__APPLE__
  #define fread fread_unlocked
  #define fwrite fwrite_unlocked
#endif
  static const int SIZE = 1 << 14;
  ~IO() { if (oi) flush(); }
  void flush() { fwrite(out, 1, oi, stdout), oi = 0; }
  char gchar() {
    if (ii == SIZE) {
      ii = 0;
      fread(in, 1, SIZE, stdin);
    }
    return in[ii++];
  }
  void pchar(const char& c) {
    out[oi++] = c;
    if (oi == SIZE) flush();
  }
  int get_int() {
    int ret = 0, sign = 0; char c;
    while ((c = gchar()) < '-');
    if (c == '-') sign = 1;
    else ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return sign ? -ret : ret;
  }
  u32 get_u32() {
    u32 ret; char c;
    while ((c = gchar()) < '0');
    ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return ret;
  }
  template <typename T>
  void put(T n) {
    if (n < 0) n = -n, pchar('-');
    static char stac[20]; int i = 0;
    do { stac[i++] = n % 10 + '0', n /= 10; } while (n);
    while (i) pchar(stac[--i]);
  }
  void pstr(const char* s) { while (*s) pchar(*(s++)); }
  char in[SIZE], out[SIZE];
  int ii = SIZE, oi = 0;
} io;

void solve() {
  int N = io.get_u32();
  vector<int> A(N);
  int sum = 0;
  rep(i, N) A[i] = io.get_u32(), sum += A[i];
  int pref = 0;
  rep(i, N) if ((pref += A[i]) >= sum / 2) {
    printf("%d\n", i + 1);
    return;
  }
}

int main() {
  clock_t beg = clock();
  solve();
  clock_t end = clock();
  fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);
  return 0;
}


#include <bits/stdc++.h>

#ifndef _WIN32
  #define getchar getchar_unlocked
  #define putchar putchar_unlocked
#endif

#define rep(i, N) for (int i = 0; i < N; ++i)

using namespace std;

typedef unsigned u32;
typedef long long i64;
typedef unsigned long long u64;

int get_int() {
  int n = 0, sign = 0; char c;
  while ((c = getchar()) < '-');
  if (c == '-') sign = 1;
  else n = c - '0';
  while ((c = getchar()) >= '0') n = n * 10 + c - '0';
  return sign ? -n : n;
}

struct IO {
#if !(_WIN32 || __APPLE__)
  #define fread fread_unlocked
  #define fwrite fwrite_unlocked
#endif
  static const int SIZE = 1 << 14;
  ~IO() { if (oi) flush(); }
  void flush() { fwrite(out, 1, oi, stdout), oi = 0; }
  char gchar() {
    if (ii == SIZE) {
      ii = 0;
      fread(in, 1, SIZE, stdin);
    }
    return in[ii++];
  }
  void pchar(const char& c) {
    out[oi++] = c;
    if (oi == SIZE) flush();
  }
  int get_int() {
    int ret = 0, sign = 0; char c;
    while ((c = gchar()) < '-');
    if (c == '-') sign = 1;
    else ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return sign ? -ret : ret;
  }
  u32 get_u32() {
    u32 ret; char c;
    while ((c = gchar()) < '0');
    ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return ret;
  }
  template <typename T>
  void put(T n) {
    if (n < 0) n = -n, pchar('-');
    static char stac[20]; int i = 0;
    do { stac[i++] = n % 10 + '0', n /= 10; } while (n);
    while (i) pchar(stac[--i]);
  }
  void pstr(const char* s) { while (*s) pchar(*(s++)); }
  char in[SIZE], out[SIZE];
  int ii = SIZE, oi = 0;
} io;

void solve() {
  int N = io.get_u32();
  vector<int> A(N);
  int sum = 0;
  rep(i, N) A[i] = io.get_u32(), sum += A[i];
  int pref = 0;
  rep(i, N) if ((pref += A[i]) * 2 >= sum) {
    printf("%d\n", i + 1);
    return;
  }
}

int main() {
  clock_t beg = clock();
  solve();
  clock_t end = clock();
  fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);
  return 0;
}


#include <bits/stdc++.h>

#ifndef _WIN32
  #define getchar getchar_unlocked
  #define putchar putchar_unlocked
#endif

#define rep(i, N) for (int i = 0; i < N; ++i)

using namespace std;

typedef unsigned u32;
typedef long long i64;
typedef unsigned long long u64;

int get_int() {
  int n = 0, sign = 0; char c;
  while ((c = getchar()) < '-');
  if (c == '-') sign = 1;
  else n = c - '0';
  while ((c = getchar()) >= '0') n = n * 10 + c - '0';
  return sign ? -n : n;
}

struct IO {
#if !(_WIN32 || __APPLE__)
  #define fread fread_unlocked
  #define fwrite fwrite_unlocked
#endif
  static const int SIZE = 1 << 14;
  ~IO() { if (oi) flush(); }
  void flush() { fwrite(out, 1, oi, stdout), oi = 0; }
  char gchar() {
    if (ii == SIZE) {
      ii = 0;
      fread(in, 1, SIZE, stdin);
    }
    return in[ii++];
  }
  void pchar(const char& c) {
    out[oi++] = c;
    if (oi == SIZE) flush();
  }
  int get_int() {
    int ret = 0, sign = 0; char c;
    while ((c = gchar()) < '-');
    if (c == '-') sign = 1;
    else ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return sign ? -ret : ret;
  }
  u32 get_u32() {
    u32 ret; char c;
    while ((c = gchar()) < '0');
    ret = c - '0';
    while ((c = gchar()) >= '0') ret = ret * 10 + c - '0';
    return ret;
  }
  template <typename T>
  void put(T n) {
    if (n < 0) n = -n, pchar('-');
    static char stac[20]; int i = 0;
    do { stac[i++] = n % 10 + '0', n /= 10; } while (n);
    while (i) pchar(stac[--i]);
  }
  void pstr(const char* s) { while (*s) pchar(*(s++)); }
  char in[SIZE], out[SIZE];
  int ii = SIZE, oi = 0;
} io;

void solve() {
  int N = io.get_u32();
  vector<int> A(N);
  int sum = 0;
  rep(i, N) A[i] = io.get_u32(), sum += A[i];
  int pref = 0;
  rep(i, N) if ((pref += A[i]) >= sum / 2) {
    printf("%d\n", i + 1);
    return;
  }
}

int main() {
  clock_t beg = clock();
  solve();
  clock_t end = clock();
  fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);
  return 0;
}


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

int fib(const int a, const int b, const int n, const int *fibarray)
{
  if(n == 0)
    return a;
  else if(n == 1)
    return b;
  else
    {
      return fibarray[n-1] ^ fibarray[n-2];
    }
}

int main(void)
{
  int num_queries;
  int a, b, n;
  int *fibarray;

  scanf("%d", &num_queries);
  for(int i = 0; i < num_queries; i++)
    {
      scanf("%d %d %d", &a, &b, &n);
      fibarray = malloc(sizeof(int) * n);
      for(int j = 0; j <= n; j++)
	{
	  fibarray[j] = fib(a, b, j, fibarray);
	}
      printf("%d\n", fibarray[n]);
      free(fibarray);
    }
  return 0;
}


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

int main(void)
{
  int num_queries;
  int a, b, n;
  int fibarray[3];

  scanf("%d", &num_queries);
  for(int i = 0; i < num_queries; i++)
    {
      scanf("%d %d %d", &a, &b, &n);
      if(n == 0 || a == b)
	printf("%d\n", a);
      else if(n == 1)
	printf("%d\n", b);
      else if(a < 1 && b < 1)
	printf("%d\n", 0);
      else{
	fibarray[0] = a;
	fibarray[1] = b;
	for(int j = 2; j <= n; j++)
	  {
	    fibarray[2] = fibarray[1] ^ fibarray[0];
	    fibarray[0] = fibarray[1];
	    fibarray[1] = fibarray[2];
	    if(fibarray[1] == fibarray[2])
	      break;
	  }
	printf("%d\n", fibarray[2]);
      }
    }
  return 0;
}


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

int main(void)
{
  int num_queries;
  int a, b, n;
  int fibarray[3];

  scanf("%d", &num_queries);
  for(int i = 0; i < num_queries; i++)
    {
      scanf("%d %d %d", &a, &b, &n);
      if(n == 0 || a == b)
	printf("%d\n", a);
      else if(n == 1)
	printf("%d\n", b);
      else if(a < 1 && b < 1)
	printf("%d\n", 0);
      else{
	fibarray[0] = a;
	fibarray[1] = b;
	for(int j = 2; j <= n; j++)
	  {
	    fibarray[2] = fibarray[1] ^ fibarray[0];
	    fibarray[0] = fibarray[1];
	    fibarray[1] = fibarray[2];
	    if(fibarray[1] == fibarray[0] && fibarray[2] == fibarray[0] &&
	       fibarray[2] == fibarray[1])
	      break;
	  }
	printf("%d\n", fibarray[2]);
      }
    }
  return 0;
}


    #include <stdio.h>
    int main(){
        int t;
        scanf("%i",&t);
        while(t--){
            int a,b,n,i,k;
            scanf("%i%i%i",&a,&b,&n);
            if(n==0)
                printf("%i",a);
            else if(n==1)
                printf("%i",b);
            else{
                for(i=2;i<=n;i++){
                    k = a ^ b;
                    a = b;
                    b = k;
                }

                printf("%i",k);
            }

            printf("\n");
        }
        return 0-0-0;
    }


    #include <stdio.h>
    int main(){
        int t;
        scanf("%i",&t);
        while(t--){
            int a,b,n,i,k;
            scanf("%i%i%i",&a,&b,&n);
            if(n%3==0)
                printf("%i",a);
            else if(n%3==1)
                printf("%i",b);
            else
                printf("%i",a^b);

            printf("\n");
        }
        return 0-0-0;
    }


#include <stdio.h>
int T, a, b, n;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d", &a, &b, &n);
    if (n) a ^= b;
    printf("%d\n", n & 1 ? b : a);
  }
}


#include<stdio.h>

int XORinacci(int n, int xor, int sum){
	if(n == 0) return sum;
	return XORinacci(n - 1, sum, xor ^ sum);
}

int main(){
	int T;
	scanf("%d", &T);

	while(T--){
		int a, b, n;
		scanf("%d %d %d", &a, &b, &n);

		printf("%d\n", XORinacci(n, b ^ a, a));
	}

	return 0;
}


#include<stdio.h>

int main(){
	int T;
	scanf("%d", &T);

	while(T--){
		int a, b, c, n;
		scanf("%d %d %d", &a, &b, &n);

		if(a != b){
			c = a ^ b;
			n %= 3;
			if(n == 0) n = a;
			if(n == 1) n = b;
			if(n == 2) n = c;
		}else{
			if(n <= 1) n = a;
			else if(n & 1) n = a;
			else n = 0;
		}

		printf("%d\n", n);
	}

	return 0;
}


#include<stdio.h>

int main(){
	int T;
	scanf("%d", &T);

	while(T--){
		int a, b, c, n;
		scanf("%d %d %d", &a, &b, &n);

		if(a != b){
			n %= 3;
			c = a ^ b;
			if(n == 0) n = a;
			if(n == 1) n = b;
			if(n == 2) n = c;
		}else{
			if(n <= 1) n = a;
			else if(n & 1) n = a;
			else n = 0;
		}

		printf("%d\n", n);
	}

	return 0;
}


#include<stdio.h>

int main(){
	int T;
	scanf("%d", &T);

	while(T--){
		int a, b, c, n, res, ans;

		scanf("%d %d %d", &a, &b, &n);

		res = n % 3;

		c = a ^ b;
		if(res == 0) ans = a;
		else if(res == 1) ans = b;
		else if(res == 2) ans = c;

		printf("%d\n", ans);
	}

	return 0;
}


#include<stdio.h>

int main(){
	int T;
	scanf("%d", &T);

	while(T--){
		int a, b, c, n;
		scanf("%d %d %d", &a, &b, &n);
		c = a ^ b;
		n %= 3;

		if(n == 0) n = a;
		if(n == 1) n = b;
		if(n == 2) n = c;

		printf("%d\n", n);
	}

	return 0;
}


#include<stdio.h>

int main(){
	int T;
	scanf("%d", &T);

	while(T--){
		int a, b, c, n, res, ans;
		scanf("%d %d %d", &a, &b, &n);
		res = n % 3;

		if(a != b){
			c = a ^ b;
			if(res == 0) ans = a;
			else if(res == 1) ans = b;
			else if(res == 2) ans = c;
		}else{
			if(n <= 1) ans = a;
			else if(n & 1) ans = a;
			else ans = 0;
		}

		printf("%d\n", ans);
	}

	return 0;
}


#include<stdio.h>

int XORinacci(int n, int xor, int sum){
	if(n <= 1) return sum;
	return XORinacci(n - 1, sum, xor ^ sum);
}

int main(){
	int T;
	scanf("%d", &T);

	while(T--){
		int a, b, n;
		scanf("%d %d %d", &a, &b, &n);

		printf("%d\n", XORinacci(n, b, a));
	}

	return 0;
}


#include<stdio.h>

int main(){
	int T;
	scanf("%d", &T);

	while(T--){
		int a, b, c, n;
		scanf("%d %d %d", &a, &b, &n);

		if(a != b){
			n %= 3;
			c = a ^ b;
			if(n == 0) n = a;
			else if(n == 1) n = b;
			else if(n == 2) n = c;
		}else{
			if(n <= 1) n = a;
			else if(n & 1) n = a;
			else n = 0;
		}

		printf("%d\n", n);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		ll a,b,n;
		scanf("%lld%lld%lld",&a,&b,&n);
		ll mid;
		if(n==0)
		{
			printf("%I64d\n",a);
			continue;
		}
		else if(n==1)
		{
			printf("%I64d\n",b);
			continue;
		}
		ll i,ans;
		for(i=2;i<=n;i++)
		{
			ans=a^b;
			a=b;
			b=ans;
		}
		printf("%I64d\n",ans);
	}
	return 0;
}


#include<stdio.h>
typedef long long ll;
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		ll a,b,n;
		scanf("%lld%lld%lld",&a,&b,&n);
		ll mid;
		if(n==0)
		{
			printf("%I64d\n",a);
			continue;
		}
		else if(n==1)
		{
			printf("%I64d\n",b);
			continue;
		}
		ll i,ans;
		ll arr[3];
		arr[0]=a^b;
		arr[1]=a;
		arr[2]=b;
		int num=(n+1)%3;
		printf("%I64d\n",arr[num]);
	}
	return 0;
}


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

int main()
{
	return 0;
}


#include<stdio.h>
typedef long long ll;
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		ll a,b,n;
		scanf("%I64d%I64d%I64d",&a,&b,&n);
		ll mid;
		if(n==0)
		{
			printf("%I64d\n",a);
			continue;
		}
		else if(n==1)
		{
			printf("%I64d\n",b);
			continue;
		}
		ll i,ans;
		for(i=2;i<=n;i++)
		{
			ans=a^b;
			a=b;
			b=ans;
		}
		printf("%I64d\n",ans);
	}
	return 0;
}


#include <stdio.h>

int main()
{
    int t;
    scanf("%d",&t);

    while(t--)
    {
        int a,b,n;
        scanf("%d %d %d",&a,&b,&n);

        if(n==0)
        {
            printf("%d\n",a);
        }

        else if(n==1)
        {
            printf("%d\n",b);
        }

        else
        {
            if(n%3==0)
            {
                printf("%d\n",a);
            }
            else if(n%3==1)
            {
                printf("%d\n",b);
            }
            else
            {
                printf("%d\n",a^b);
            }
        }
    }

    return 0;
}


#include <stdio.h>

int main()
{
    int t;
    scanf("%d",&t);

    while(t--)
    {
        int a,b,n;
        scanf("%d %d %d",&a,&b,&n);

        if(n==0)
        {
            printf("%d",a);
        }

        else if(n==1)
        {
            printf("%d",b);
        }

        else
        {
            if(n%3==0)
            {
                printf("%d",a);
            }
            else if(n%3==1)
            {
                printf("%d",b);
            }
            else
            {
                printf("%d",a^b);
            }
        }
    }

    return 0;
}


#include<stdio.h>
long int fib(long int n,long int a,long int b )
{
 long int c,i;
  if( n == 0)
    return a;
  for (i = 2; i <= n; i++)
  {
     c = a^b;
     a = b;
     b = c;
  }
  return b;
}

int main ()
{
   long  int t,n,a,b;
    scanf("%ld", &t);
    while(t--)
    {
        scanf("%ld%ld%ld", &a, &b, &n);
       printf("%ld\n", fib(n,a,b));
    }
    return 0;
}


#include<stdio.h>

int main ()
{
   long  int t,n,a,b;
    scanf("%ld", &t);
    while(t--)
    {
        scanf("%ld%ld%ld", &a, &b, &n);
       if((n-1)%3==0)
        printf("%d\n", b);
       else if(((n-1)%3==1))
        printf("%d\n", a^b);
       else
        printf("%d\n", a);
    }
    return 0;
}


#include <stdio.h>

#define N 1000000000

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		static int f[N];
		int a, b, n, i;

		scanf("%d%d%d", &a, &b, &n);
		f[0] = a;
		f[1] = b;
		for (i = 2; i <= n; i++)
			f[i] = f[i - 1] ^ f[i - 2];
		printf("%d\n", f[n]);
	}
	return 0;
}


#include <stdio.h>

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		int a, b, n;

		scanf("%d%d%d", &a, &b, &n);
		printf("%d\n", n % 3 == 0 ? a : n % 3 == 1 ? b : a ^ b);
	}
	return 0;
}


#include <stdio.h>

int main() {
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    long long int a,b,n,c,i;
	    scanf("%lld %lld %lld",&a,&b,&n);
	    if(n==0)
	      printf("%lld\n",a);
	    else if(n==1)
	      printf("%lld\n",b);
	    else
	    {
	        for(i=2;i<=n;i++)
	        {
	            c = a ^ b;
	            a = b;
                b = c;
	        }
	        printf("%lld\n",c);
	    }

	}
	return 0;
}


#include <stdio.h>

int main() {
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    long long int a,b,n;
	    scanf("%lld %lld %lld",&a,&b,&n);
	    if(n==0)
	      printf("%lld\n",a);
	    else if(n==1)
	      printf("%lld\n",b);
	    else if(n==2)
	       printf("%lld\n",(a^b));
	   else
	   {
	       if(n%3==0)
	         printf("%lld\n",a);
	       else if(n%3==1)
	         printf("%lld\n",b);
	       else
	         printf("%lld\n",(a^b));
	   }

	}
	return 0;
}


#include <stdio.h>
int main()
{
int T,i,a,b,n;
scanf("%d",&T);
for(i=0;i<T;i++)
{
scanf("%d %d %d",&a,&b,&n);
if( n%3 == 0)
printf("%d\n",a);
if( n%3 == 1)
printf("%d\n",b);
if(n%3 == 2)
printf("%d\n", a^b);
}
return 0;
}


#include<bits/stdc++.h>
 using namespace std;
 int main() {
     int test,a,b,n;
     cin>>test;
     while(test--){
         cin>>a>>b>>n;
         if(n%3==0)
        cout<<a;
        if(n%3==1)
        cout<<b;
        if(n%3==2)
        cout<<a^b;
        }
    return 0;
    }


#include<stdio.h>
 int main() {
     int t,a,b,n;
     scanf("%d\n",&t);
     while(t--){
        scanf("%d %d %d\n",&a,&b,&n);
        if(n%3==0)
        printf("%d",a);
        else if(n%3==1)
        printf("%d",b);
        else
        printf("%d",a^b);
        }
    return 0;
    }


#include <stdio.h>
 int fibo(int a,int b,int n)
 {
      if(n==0)
      return a;
      if(n==1)
      return b;
      return fibo(a,b,n-1)^fibo(a,b,n-2);
 }
int main() {
	int t;
	scanf("%d",&t);
	while(t!=0){
	    int a,b,n;
	    scanf("%d %d %d",&a,&b,&n);
	    int x = fibo(a,b,n);
	    printf("%d\n",x);
	}
	return 0;
}


#include <stdio.h>
 int fibo(int a,int b,int n)
 {
      if(n==0)
      return a;
      if(n==1)
      return b;
      return fibo(a,b,n-1)^fibo(a,b,n-2);
 }
int main() {
	int t;
	scanf("%d",&t);
	while(t!=0){
	    int a,b,n;
	    scanf("%d %d %d",&a,&b,&n);
	    int x = fibo(a,b,n);
	    printf("%d\n",x);
        t--;
	}
	return 0;
}


#include<stdio.h>
 int main() {
     int t,a,b,n;
     scanf("%d\n",&t);
     while(t--){
        scanf("%d %d %d\n",&a,&b,&n);
        if(n%3==0)
        printf("%d\n",a);
        else if(n%3==1)
        printf("%d\n",b);
        else
        printf("%d\n",a^b);
        }
    return 0;
    }


#include <stdio.h>
 int fibo(long int a,long int b,long int n)
 {
      if(n==0)
      return a;
      if(n==1)
      return b;
      return fibo(a,b,n-1)^fibo(a,b,n-2);
 }
int main() {
	long int t;
	scanf("%ld\n",&t);
	while(t!=0){
	    long int a,b,n;
	    scanf("%ld %ld %ld",&a,&b,&n);
	    long int x = fibo(a,b,n);
	    printf("%ld\n",x);
        t--;
	}
	return 0;
}


include<bits/stdc++.h>
 using namespace std;
 int main() {
     int test,a,b,n;
     cin>>test;
     while(test--){
         cin>>a>>b>>n;
         if(n%3==0)
        printf("%d\n",a);
        if(n%3==1)
        printf("%d\n",b);
        if(n%3==2)
        printf("%d\n",a^b);
        }
    }


#include<iostream>
 using namespace std;
 int main() {
     int test,a,b,n;
     cin>>test;
     while(test--){
         cin>>a>>b>>n;
         if(n%3==0)
        cout<<a;
        if(n%3==1)
        cout<<b;
        if(n%3==2)
        cout<<a^b;
        }
    return 0;
    }


#include <stdio.h>

int main() {

    int t, a, b, n, tmp;

    scanf("%d", &t);

    for (int i=0; i<t; ++i){
        scanf("%d%d%d", &a, &b, &n);

        if (n==0) printf("%d\n", a);
        else if (n==1) printf("%d\n", b);
        else{
            for (int i=2; i<=n; i++){
                tmp=a;
                a=b;
                b^=tmp;
            }

            printf("%d\n", b);
        }
    }

    return 0;
}


#include <stdio.h>

int XORinacci(int a, int b, int n){
    if (n%3==0) return a;
    if ((n+2)%3==0) return b;
    return a^b;
}

int main(){
    int T, a, b, n;

    scanf("%d", &T);

    for (int i=0; i<T; ++i){
        scanf("%d%d%d", &a, &b, &n);

        printf("%d\n", XORinacci(a, b, n));
    }
    return 0;
}


#include <stdio.h>

int XORinacci(int a, int b, int n){
    if (n==0) return a;
    if (n==1) return b;
    if (a==b && (n-1)%3==0) return 0;
    if (a==b) return a;

    int f1=a, f2=b, tmp;

    for (int i=2; i<=n; i++){
        tmp=f2;
        f2^=f1;
        f1=tmp;
    }
    return f2;
}

int main(){
    int T, a, b, n;

    scanf("%d", &T);

    for (int i=0; i<T; ++i){
        scanf("%d%d%d", &a, &b, &n);

        printf("%d\n", XORinacci(a, b, n));
    }
    return 0;
}


#include <stdio.h>

int XORinacci(int a, int b, int n){
    if (n==0) return a;
    if (n==1) return b;

    int f1=a, f2=b, tmp;

    for (int i=2; i<=n; i++){
        tmp=f2;
        f2^=f1;
        f1=tmp;
    }
    return f2;
}

int main(){
    int T, a, b, n;

    scanf("%d", &T);

    for (int i=0; i<T; ++i){
        scanf("%d%d%d", &a, &b, &n);

        printf("%d\n", XORinacci(a, b, n));
    }
    return 0;
}


#include <stdio.h>

int XORinacci(int a, int b, int n){
    if (n==0) return a;
    if (n==1) return b;
    if (a==b && (n+1)%3==0) return 0;
    if (a==b) return a;

    int f1=a, f2=b, tmp;

    for (int i=2; i<=n; i++){
        tmp=f2;
        f2^=f1;
        f1=tmp;
    }
    return f2;
}

int main(){
    int T, a, b, n;

    scanf("%d", &T);

    for (int i=0; i<T; ++i){
        scanf("%d%d%d", &a, &b, &n);

        printf("%d\n", XORinacci(a, b, n));
    }
    return 0;
}


#include <stdio.h>
int main()
{
long long t,x,n,a,b;
scanf("%lld",&t);
for(x=0;x<t;x++)
{
    scanf("%lld %lld %lld",&a,&b,&n);
    if(n%3==0)printf("%lld\n",a);
    else
    if(n%3==1)printf("%lld\n",b);
    else
    printf("%lld\n",(a^b));
}
}


#include <stdio.h>
void main()
{
	short n,x,no,a,b,c,y;
	scanf("%hu",&n);
	for(x=0;x<n;x++)
	{
		scanf("%hu %hu %hu",&a,&b,&no);
		if(no>1)
		{
			for(y=2;y<=no;y++)
		{
			c=b^a;
			a=b;
			b=c;
		}
		printf("%hu",c);
		}
		else
			if(no==1)printf("%hu", b);
			else
				if(no==0)printf("%hu", a);
	printf("\n");
	}
}


#include <stdio.h>
void main()
{
	int n,x,no,a,b,c,y;
	scanf("%d",&n);
	for(x=0;x<n;x++)
	{
		scanf("%d %d %d",&a,&b,&no);
		if(no>1)
		{
			for(y=2;y<=no;y++)
		{
			c=b^a;
			a=b;
			b=c;
		}
		printf("%d",c);
		}
		else
			if(no==1)printf("%d", b);
			else
				if(no==0)printf("%d", a);
	printf("\n");
	}
}


#include <stdio.h>
void main()
{
	int n,x,no,a,b,c,y;
	scanf("%d \n",&n);
	for(x=0;x<n;x++)
	{
		scanf("%d %d %d",&a,&b,&no);
		if(no>1)
		{
			for(y=2;y<=no;y++)
		{
			c=b^a;
			a=b;
			b=c;
		}
		printf("%d",c);
		}
		else
			if(no==1)printf("%d", b);
			else
				if(no==0)printf("%d \n", a);
	printf("\n");
	}
}


#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
    long long int x,i,a,b,c;
    scanf("%lld",&x);
    for(i=0;i<x;i++)
    {
        scanf("%lld%lld%lld",&a,&b,&c);
        if(c%3==0)
        {
            printf("%lld\n",a);
        }
        else if(c%3==1)
        {
            printf("%lld\n",b);
        }
        else
        {
            printf("%lld\n",a^b);
        }
    }
}


#include<stdio.h>
int a,b,T,l,n;
int main()
{
    scanf("%d",&T);
    for(int i=1;i<=T;i++)
    {scanf("%d%d%d",&a,&b,&n);
        for(int j=2;j<=n;j++)
        {
            l=a^b;
            a=b;b=l;
        }
    switch(n)
    {
        case 0:printf("%d\n",a);break;
        case 1:printf("%d\n",b);break;
        default : printf("%d\n",l);
    }

}
}


#include<stdio.h>
int main()
{
    long a,b,n,m,p,l,T;
    scanf("%ld",&T);
    for(int j=1;j<=T;j++)
    {
        scanf("%ld%ld%ld",&a,&b,&n);
        p=(a^b);
        m=b;
        switch(n)
        {
        case 0:printf("%ld\n",a);break;
        case 1:printf("%ld\n",b);break;
        default:
        {
        for(int i=3;i<=n;i++)
        {
        l=p;p=(p^m);m=l;
        }
        printf("%ld\n",p);
        }
        }
    }
}


#include<stdio.h>
int a,b;
int fib(int n)
{
int f[n+2];
int i;
f[0] = a;
f[1] = b;
for (i = 2; i <= n; i++)
f[i] =(int)(f[i-1] ^ f[i-2]);
return f[n];
}
int main ()
{
    int T,n;
    scanf("&d",&T);
    for(int j=1;j<=T;j++)
    {
        scanf("%d%d%d",&a,&b,&n);
        printf("%d",fib(n));
    }
}


#include<stdio.h>

int a,b,T,m,n;
int fn(int x)
{
    if(x==0)
    return a;
    if(x==1)
    return b;
    else
    return fn(x-2)^fn(x-1);
}
int main()
{
    for(int i=1;i<=T;i++)
    {
    scanf("%d\n%d%d%d",&T,&a,&b,&n);
    printf("%d\n",fn(n));
    }
}


#include<stdio.h>
int a,b;
int fib(int n)
{
int f[n+2];
int i;
f[0] = a;
f[1] = b;
for (i = 2; i <= n; i++)
f[i] = f[i-1] ^ f[i-2];
return f[n];
}
int main ()
{
    int T,n;
    scanf("&d",&T);
    for(int i=0;i<=T;i++)
    {
        scanf("%d%d%d",&a,&b,&n);
        printf("%d",fib(n));
    }
}


#include<stdio.h>

int main(){
	int t;
	scanf(" %d",&t);
	while(t--){
		int a,b,c;
		scanf(" %d %d %d",&a,&b,&c);
		int nums[] = {a,b,a^b};
		printf("%d\n",nums[c%3]);
	}
}


#include<stdio.h>

int a,b,T,m,n;
int fn(int x)
{
    if(x==0)
    return a;
    if(x==1)
    return b;
    else
    return fn(x-2)^fn(x-1);
}
int main()
{
    scanf("%d",&T);
    for(int i=1;i<=T;i++)
    {
    scanf("%d%d%d",&a,&b,&n);
    printf("%d\n",fn(n));
    }
}


#include<stdio.h>
int main()
{
    long a,b,n,m,p,l,T;
    scanf("%ld",&T);
    for(int j=1;j<=T;j++)
    {
        scanf("%ld%ld%ld",&a,&b,&n);
        p=(a^b);
        m=b;
        if(n==0)
        printf("%ld\n",a);
        else if(n==1)
        printf("%ld\n",b);
        else
        {
        for(int i=3;i<=n;i++)
    {
        l=p;       p=(p^m);m=l;
    }
    printf("%ld\n",p);}
    }
}


#include<stdio.h>
int a,b,T,m,n;
int fn(int x)
{
    int o=a,p=b,l;
    for(int i=2;i<=n;i++)
    {
        l=p^o;
        o=p;
        p=l;
    }
    switch(x)
    {
        case 0:return a;break;
        case 1:return b;break;
        default : return l;
    }

}
int main()
{
    scanf("%d",&T);
    for(int i=1;i<=T;i++)
    {
    scanf("%d%d%d",&a,&b,&n);
    printf("%d\n",fn(n));
    }
}


#include <stdio.h>
int main ()
{
    long long int t,a,b,n,i,j;
    scanf("%lld",&t);
    for(i=1;i<=t;i++)
    {
        scanf("%lld %lld %lld",&a,&b,&n);
        if(n%3==0)
        {
            printf("%lld\n",a);
            continue;
        }
        else if(n%3==1)
        {
            printf("%lld\n",b);
            continue;
        }
        else
        {
            printf("%lld\n",a^b);
            continue;
        }
    }
    return 0;
}


#include <stdio.h>
int main ()
{
    long long int t,a,b,n,s,i,j;
    scanf("%lld",&t);
    for(i=1;i<=n;i++)
    {
        scanf("%lld %lld %lld",&a,&b,&n);
        if(n==0)
        {
            printf("%lld\n",a);
            continue;
        }
        else if(n==1)
        {
            printf("%lld\n",b);
            continue;
        }
        else
        {
            for(j=2;j<=n;j++)
            {
                s=a^b;
                if(j==n)
                {
                    printf("%lld\n",s);
                }
                else
                {
                    a=b;
                    b=s;
                }
            }
        }
    }
    return 0;
}


#include <stdio.h>
int main ()
{
    long long int t,a,b,n,s,i,j;
    scanf("%lld",&t);
    for(i=1;i<=t;i++)
    {
        scanf("%lld %lld %lld",&a,&b,&n);
        if(n==0)
        {
            printf("%lld\n",a);
            continue;
        }
        else if(n==1)
        {
            printf("%lld\n",b);
            continue;
        }
        else
        {
            for(j=2;j<=n;j++)
            {
                s=a^b;
                if(j==n)
                {
                    printf("%lld\n",s);
                }
                else
                {
                    a=b;
                    b=s;
                }
            }
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include <conio.h>

#define ll long long

void run_case(void)
{
    ll a, b, n;
    ll ans;
    int x;

    scanf("%lld %lld %lld", &a, &b, &n);
    x = n%3;

    if(!x) ans = a;
    else if(!(x-1)) ans = b;
    else ans = a^b;

    printf("%lld\n", ans);
}

int main(int argc, char *argv[])
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else
    // online submission
    #endif

    int t;

    scanf("%d", &t);
    while(t--)
    run_case();

    return 0;
}


#include<stdio.h>

void Func(){
	long a,b,n,i,f,r;
	scanf("%ld%ld%ld",&a,&b,&n);

	if(n%3==0) printf("%ld\n",a);
	else if(n%3==1) printf("%ld\n",b);
	else printf("%ld\n",a^b);
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
	Func();
	}
}


#include<stdio.h>

void Func(){
	long a,b,n,i,f,r;
	scanf("%ld%ld%ld",&a,&b,&n);

	if(n==0) printf("%ld\n",a);
	else if(n==1) printf("%ld\n",b);
	else{
	for(i=2;i<=n;i++){
		r=a^b;
		a=b;
		b=r;
	}
	printf("%ld\n",r);
	}
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
	Func();
	}
}


#include<stdio.h>
#include<stdlib.h>
int re(int a, int b, int n)
{
    if (n==0)
    {
        return a;
    }
    return a^b;
}
int main()
{
    int a, b, n,t;
    scanf("%d", &t);
    while(t--)
    {
    scanf("%d%d%d", &a,&b,&n);
    int x=re(a,b,n);
    printf("%d\n", x);
    }
    return 0;

}


#include<stdio.h>
#include<stdlib.h>
int re(int a, int b, int n)
{
    if (n==0)
    {
        return a;
    }
    else if(n>1)
        return a^b;
}
int main()
{
    int a, b, n,t;
    scanf("%d", &t);
    while(t--)
    {
    scanf("%d%d%d", &a,&b,&n);
    int x=re(a,b,n);
    printf("%d\n", x);
    }
    return 0;

}


#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#define ll long long int

int main(void) {
    int t;
    scanf("%d",&t);

    while(t--){
ll  a,b,n,ans=0;
    ll k;
    scanf("%lld%lld%lld",&a,&b,&n);
if(n==0)
printf("%lld\n",a);
else if(n==1)
printf("%lld\n",b);
else
{

     for(int i=2;i<=n;i++){
          k=a^b;
          a=b;
          b=k;
     }
     printf("%lld\n",b);
    }
    }

    return 0;
}


#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#define ll long long int

int main(void) {
    int t;
    scanf("%d",&t);

    while(t--){
ll  a,b,n,ans=0;
    scanf("%lld%lld%lld",&a,&b,&n);
    ll val = n%3;
    if(val==0)
    printf("%lld\n",a);
    else if(val==1)
    printf("%lld\n",b);
    else
    printf("%lld\n",a^b);
    }
    return 0;
}


#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#define ll long long int
void fib(ll x,ll y,ll  n)
{
  ll f[n+2];
  ll i;

  f[0] = x;
  f[1] = y;

  for (i = 2; i <= n; i++)
  {
      f[i] = (f[i-1]^ f[i-2]);
  }
  printf("%lld\n",f[n]);
}

int main(void) {
    int t;
    scanf("%d",&t);

    while(t--){
    ll a,b,k,ans=0;
    scanf("%lld%lld%lld",&a,&b,&k);

    fib(a,b,k);

    }

    return 0;
}


#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#define ll long long int

int main(void) {
    int t;
    scanf("%d",&t);

    while(t--){
int  a,b,n,ans=0;
    ll k;
    scanf("%d%d%d",&a,&b,&n);
if(n==0)
printf("%d\n",a);
else if(n==1)
printf("%d\n",b);
else
{

     for(int i=2;i<=n;i++){
          k=a^b;
          a=b;
          b=k;
     }
     printf("%lld\n",b);
    }
    }

    return 0;
}


#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#define ll long long int
void fib(int  x,int  y,int   n)
{
  ll f[n+2];
  int  i;

  f[0] = x;
  f[1] = y;

  for (i = 2; i <= n; i++)
  {
      f[i] = (f[i-1]^ f[i-2]);
  }
  printf("%lld\n",f[n]);
}

int main(void) {
    int t;
    scanf("%d",&t);

    while(t--){
    ll a,b,k,ans=0;
    scanf("%d%d%d",&a,&b,&k);

    fib(a,b,k);

    }

    return 0;
}


#include <stdio.h>
#include<math.h>
#include<stdlib.h>
#define ll long long int

int main(void) {
    int t;
    scanf("%d",&t);

    while(t--){
int  a,b,n,ans=0;

    scanf("%d%d%d",&a,&b,&n);
    ll f[n+1];
     f[0]=a;
     f[1]=b;
     for(int i=2;i<=n;i++){
         f[i]=(f[i-1]^f[i-2]);
     }
     printf("%lld\n",f[n]);
    }

    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,n,x;
    scanf("%lld",&x);
    while(x--)
    {
        scanf("%lld %lld %lld",&a,&b,&n);
   if(n%3==0) printf("%lld\n",a);
   else if(n%3==1) printf("%lld\n",b);
   else
        printf("%lld\n",a^b);
    }
}


#include<stdio.h>
int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        int a,b,n;
        scanf("%d%d%d",&a,&b,&n);
        if(n==0){
            printf("%d\n",a);
        }else if(n==1){
            printf("%d\n",b);
        }else if(n==2){
            printf("%d\n",a^b);
        }else if(n%3==0){
            printf("%d\n",0^a);
        }else if((n-1)%3==0){
            printf("%d\n",0^b);
        }else{
            printf("%d\n",0^a^b);
        }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n;
    scanf("%lld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);
        long long int s;
        for(j=2;j<=n;j++)
        {
            s=b^a;
            a=b;
            b=s;

        }
        printf("%lld\n",s);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n;
    scanf("%lld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);
        long long int s;
        for(j=2;j<=n;j++)
        {
            s=b^a;
            a=b;
            b=s;

        }
        if(n=0){
        printf("%lld\n",a);
        }
        else if(n=1){
            printf("%lld\n",b);
        }
        else{
            printf("%lld",s);
        }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n,x,y;
    scanf("%lld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);

        if(n%3==0){
        printf("%lld\n",a);
        }
        else if(n%3==1){
            printf("%lld\n",b);
        }
        else{
            printf("%lld\n",a^b);
        }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n;
    scanf("%lld",&t);
    printf("%lld\n",t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);
        printf("%lld %lld %lld\n",a,b,n);
        long long int x[n];
        x[0]=a;
        x[1]=b;
        for(j=2;j<=n;j++)
        {
            x[j]= x[j-1]^x[j-2];
        }
        printf("%lld\n",x[n]);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long int a,b,t,j,i,n;
    scanf("%ld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%ld",&a);
        scanf("%ld",&b);
        scanf("%ld",&n);
        int x[n];
        x[0]=a;
        x[1]=b;
        for(j=2;j<=n;j++)
        {
            x[j]= x[j-1]^x[j-2];
        }
        printf("%ld\n",x[n]);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n,x,y;
    scanf("%lld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);
        x=a;
        y=b;
        long long int s;
        for(j=2;j<=n;j++)
        {
            s=x^y;
            x=y;
            y=s;

        }
        if(n==0){
        printf("%lld\n",a);
        }
        else if(n==1){
            printf("%lld\n",b);
        }
        else{
            printf("%lld",s);
        }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n;
    scanf("%ld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);
        int x[n];
        x[0]=a;
        x[1]=b;
        for(j=2;j<=n;j++)
        {
            x[j]= x[j-1]^x[j-2];
        }
        printf("%lld\n",x[n]);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n,x,y;
    scanf("%lld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);
        x=a;
        y=b;
        long long int s;
        for(j=2;j<=n;j++)
        {
            s=x^y;
            x=y;
            y=s;

        }
        if(n==0){
        printf("%lld\n",a);
        }
        else if(n==1){
            printf("%lld\n",b);
        }
        else{
            printf("%lld\n",s);
        }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n;
    scanf("%lld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);
        long long int x[n];
        x[0]=a;
        x[1]=b;
        for(j=2;j<=n;j++)
        {
            x[j]= x[j-1]^x[j-2];
        }
        printf("%lld\n",x[n]);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,t,j,i,n;
    scanf("%lld",&t);
    printf("%lld\n",t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        scanf("%lld",&n);
        printf("%lld %lld %lld\n",a,b,n);
        long long int x[n];
        x[0]=a;
        x[1]=b;
        for(j=2;j<=n;j++)
        {
            x[j]= x[j-1]^x[j-2];
        }
        printf("%lld\n",x[n]);
    }
    return 1;
}


#include<stdio.h>
int main()
{
    long long int a,b,n,test,t,x,k;
    scanf("%lld",&test);
    for(t=1;t<=test;t++){
        scanf("%lld %lld %lld",&a,&b,&n);
        if(n%3==0)printf("%lld\n",a);
        else if(n%3==1)printf("%lld\n",b);
        else printf("%lld\n",a^b);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int a,b,n,test,t,x,k;
    scanf("%lld",&test);
    for(t=1;t<=test;t++){
        scanf("%lld %lld %lld",&a,&b,&n);
        if(n==0){
            printf("%lld\n",a);continue;
        }
        else if(n==1){
            printf("%lld\n",b);continue;
        }
        for(k=2;k<=n;k++){
            x=b^a;
            a=b;
            b=x;
        }
        printf("%lld\n",x);
    }
    return 0;
}


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

int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        int a,b,n;
        scanf("%d %d %d",&a,&b,&n);
        int k ;
        if(n == 0){
            printf("%d\n",a);
        }
        else if(n == 1){
            printf("%d\n",b);
        }
        else{
            for(int i=2;i<=n;i++){
                k = a^b;
                a=b;
                b=k;
            }
            printf("%d\n",k);
        }
    }
}


#include <stdio.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        int a,b,n;
        scanf("%d %d %d",&a,&b,&n);
        n = n%3;
        if(n == 0){
            printf("%d\n",a);
        }
        else if(n==1){
            printf("%d\n",b);
        }
        else if(n==2){
            printf("%d\n",a^b);
        }

    }
}


#include<stdio.h>
#define max 10000
long long a,n,b;
int A[max];
long long calculate(long long  k)
{
	if(k==1)
	return A[k]  = b;
	if(k == 0)
	return A[k]  = a;
	return A[k] = calculate(k-1)^calculate(k-2);
	return A[n];
}
int main()
{
	long i,t;
	scanf("%ld",&t);
	for(i=1;i<=t;i++)
	{
	scanf("%I64d",&a);
	scanf("%I64d",&b);
	scanf("%I64d",&n);
	if(n>=2)
	{
	int ans = calculate(2);
	printf("%d\n",ans);
    }
	else
	n == 0?printf("%d\n",a):printf("%d\n",b);
    }
	return 0;
}


#include<stdio.h>
int main()
{
	long j,t;
	scanf("%ld",&t);
	for(j=1;j <= t;j++)
	{
	long long n,a,b;
	scanf("%I64d",&a);
	scanf("%I64d",&b);
	scanf("%I64d",&n);
	long long A[n];
	A[0] = a;
	A[1] = b;
	if(n>=2)
	{
		long long i;
	for(i=2;i<=n;i++)
	{
		A[i] = A[i-1]^A[i-2];
	}
	printf("%ld\n",A[n]);
    }
	else
	n == 0?printf("%d\n",a):printf("%d\n",b);
    }
	return 0;
}


#include<stdio.h>
#define max 10000
long long a,n,b;
int A[max];
long long calculate(long long  k)
{
	if(k==1)
	return A[k]  = b;
	if(k == 0)
	return A[k]  = a;
	return A[k] = calculate(k-1)^calculate(k-2);
	return A[n];
}
int main()
{
	long i,t;
	scanf("%ld",&t);
	for(i=1;i<=t;i++)
	{
	scanf("%I64d",&a);
	scanf("%I64d",&b);
	scanf("%I64d",&n);
	if(n>=2)
	{
	int ans = calculate(2);
	printf("%d",ans);
    }
	else
	n == 0?printf("%d\n",a):printf("%d\n",b);
    }
	return 0;
}


#include<stdio.h>
int main()
{
	long j,t;
	scanf("%ld",&t);
	for(j=1;j <= t;j++)
	{
	long long n,a,b;
	scanf("%I64d",&a);
	scanf("%I64d",&b);
	scanf("%I64d",&n);
	long long A[n];
	A[0] = a;
	A[1] = b;
	if(n>=2)
	{
		long long i;
	for(i=2;i<=n;i++)
	{
		A[i] = A[i-1]^A[i-2];
	}
	printf("%I64d\n",A[n]);
    }
	else
	n == 0?printf("%d\n",a):printf("%d\n",b);
    }
	return 0;
}


    #include<stdio.h>
    int main()
    {
        int t,n,a,b;
        scanf("%d",&t);
        for(int i=0;i<t;i++){
            scanf("%d %d %d",&a,&b,&n);
            if(n%3==0){
                printf("%d\n",a);
            }
            else if(n%3==1){
                printf("%d\n",b);
            }
            else{
                printf("%d\n",a^b);
            }
        }
        return 0;
    }


#include<stdio.h>
int main()
{
    int t,n,a,b;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
        scanf("%d %d %d",&n,&a,&b);
        if(n%3==0){
            printf("%d\n",a);
        }
        else if(n%3==1){
            printf("%d\n",b);
        }
        else{
            printf("%d\n",a^b);
        }
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int m;
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
    int a,b,n;
    scanf("%d%d%d",&a,&b,&n);
    if(n%3==0)
    printf("%d\n",a);
    if(n%3==1)
    printf("%d\n",b);
    if(n%3==2)
    printf("%d\n",a^b);
    }
    return 0;
}


#include<stdio.h>
int main(void )
{     int t;
     scanf("%d",&t);
	while (t--){

	int a,b,n,c;
	scanf("%d %d %d",&a,&b,&n);
	for(int i=1;i<n;i++)
	{
		c=a^b;
		a=b;
		b=c;
	}
	if(n==0)
	{
	printf("%d\n",a);

	}if(n==1)
{
		printf("%d\n",b);
		}
	if(n>1)
	printf("%d\n",c);

}
return 0;
}


#include<stdio.h>
int main(void )
{     int t;
     scanf("%d",&t);
	while (t--){

	int a,b,n,c;
	scanf("%d %d %d",&a,&b,&n);
	for(int i=1;i<n;i++)
	{
		c=a^b;
		a=b;
		b=c;
	}
	if(n==0)
	{
	printf("%d",a);
		continue;
	}if(n==1)
{
		printf("%d",b);
		continue;}
	else
	printf("%d\n",c);
}
return 0;
}


#include<stdio.h>
int xonaci(int a,int b,int n)
{
	if (n==0)
	return a;
	if(n==1)
	return b;
	return xonaci(a,b,n-1)^xonaci(a,b,n-2);

}
int main(void )
{     int t;
     scanf("%d",&t);
	while (t--){

	int a,b,n;
	scanf("%d %d %d",&a,&b,&n);
	printf("%d",xonaci(a,b,n));
}
return 0;
}


#include<stdio.h>
int main(void )
{     int t;
     scanf("%d",&t);
	while (t--){

	int a,b,n,c;
	scanf("%d %d %d",&a,&b,&n);
	for(int i=1;i<n;i++)
	{
		c=a^b;

		a=b;
		b=c;
	}
	printf("%d\n",c);
}
return 0;
}


    #include<stdio.h>
    int main(void )
    {     int t;
         scanf("%d",&t);
    	while (t--){

    	int a,b,n,c;
    	scanf("%d %d %d",&a,&b,&n);

    		c=a^b;

    	if(n==0)
    	{
    	printf("%d\n",a);

    	}if(n==1)
    {
    		printf("%d\n",b);
    		}
    	if(n%3==1)
    	printf("%d\n",a);
    	if(n%3==2)
    	printf("%d\n",b);
    	if(n%3==3)
    	printf("%d\n",c);
    }
    return 0;
    }


    #include<stdio.h>
    int main(void )
    {     int t;
         scanf("%d",&t);
    	while (t--){

    	int a,b,n,c;
    	scanf("%d %d %d",&a,&b,&n);

    		c=a^b;

    	if(n%3==0)
    	{
    	printf("%d\n",a);

    	}if(n%3==1)
    {
    		printf("%d\n",b);
    		}
    	if(n%3==2)
    	printf("%d\n",c);
    }
    return 0;
    }


#include <bits/stdc++.h>
#define  pb push_back
#define  pf push_front
#define  S second
#define  F first
#define ra ragham
#define ll long long
#define ld double
//#define ll int
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

using namespace std;
//typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> order_set;
typedef pair<ll,ll> pii ;
typedef pair<long double,ll> pldi ;
typedef pair<long double,pii> pldii ;
typedef pair<int,char> cii ;
typedef pair<ll,pii> piii ;
//setprecision(8)
//ios_base::sync_with_stdio(false);
//ifstream fin ("in.txt");
//ofstream fout ("out.txt");
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout;
//string mabda1  = "abcdefghijklmnopqrstuvwxyz";
//string mabda2  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int maxn = 2*1e5+100 ;
int a[maxn] ;
int b[maxn] ;
vector<int>v[maxn] ;
int F[maxn] ;
pii q[maxn] ;
ll t[maxn] ;
ll ans[maxn] ;
ll n , Q ;
void add(ll i)
{
    for(ll y= i ; y <= n; y+=(y&(-y)))
        F[y]++;
}
ll get(ll i)
{
    ll d = 0 ;
    for(ll y = i ; y > 0;  y-=(y&(-y)))
        d+=F[y] ;
    return d ;
}
bool amx(int i , int j )
{
    return q[i].S<q[j].S ;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>n>>Q;
    for(ll y= 1 ; y <= n; y++)
        cin>>a[y],b[a[y]] = y ;
    for(ll y= 1 ; y <= n; y++)
        for(ll i = y;  i  <= n ; i+=y)
        {
            v[y].pb(b[i]);
            if(y!=i)
             v[i].pb(b[y]) ;
        }
    for(ll y= 0 ; y < Q ; y++)
        cin>>q[y].F>>q[y].S,t[y]=y;

    sort(t,t+Q,amx);
    int po = 0 ;
    for(int i = 1 ; i  <= n ; i++)
    {
        for(ll y=  0 ; y < v[a[i]].size() ; y++)
        {
            ll x = v[a[i]][y];
            if(x <= i)
                add(x);
        }
        while(q[t[po]].S<=i&&po<Q)
            ans[t[po]] = get(q[t[po]].S)-get(q[t[po]].F-1),po++ ;
    }
    for(ll y= 0 ; y < Q ; y++)
        cout<<ans[y]<<endl;

}


#include <bits/stdc++.h>
#define  pb push_back
#define  pf push_front
#define  S second
#define  F first
#define ra ragham
#define ll long long
#define ld double
//#define ll int
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

using namespace std;
//typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> order_set;
typedef pair<ll,ll> pii ;
typedef pair<long double,ll> pldi ;
typedef pair<long double,pii> pldii ;
typedef pair<int,char> cii ;
typedef pair<ll,pii> piii ;
//setprecision(8)
//ios_base::sync_with_stdio(false);
//ifstream fin ("in.txt");
//ofstream fout ("out.txt");
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout;
//string mabda1  = "abcdefghijklmnopqrstuvwxyz";
//string mabda2  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int maxn = 2e5+100 ;
int a[maxn] ;
int b[maxn] ;
vector<int>v[maxn] ;
int F[maxn] ;
pii q[maxn] ;
ll t[maxn] ;
ll ans[maxn] ;
ll n , Q ;
void add(ll i)
{
    for(ll y= i ; y <= n; y+=(y&(-y)))
        F[y]++;
}
ll get(ll i)
{
    ll d = 0 ;
    for(ll y = i ; y > 0;  y-=(y&(-y)))
        d+=F[y] ;
    return d ;
}
bool amx(int i , int j )
{
    return q[i].S<q[j].S ;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>n>>Q;
    for(ll y= 1 ; y <= n; y++)
        cin>>a[y],b[a[y]] = y ;
    for(ll y= 1 ; y <= n; y++)
        for(ll i = y;  i  <= n ; i+=y)
        {
            v[y].pb(b[i]);
            if(y!=i)
             v[i].pb(b[y]) ;
        }
    for(ll y= 0 ; y < Q ; y++)
        cin>>q[y].F>>q[y].S,t[y]=y;

    sort(t,t+n,amx);
    int po = 0 ;
    for(int i = 1 ; i  <= n ; i++)
    {
        for(ll y=  0 ; y < v[a[i]].size() ; y++)
        {
            ll x = v[a[i]][y];
            if(x <= i)
                add(x);
        }
        while(q[t[po]].S<=i&&po<Q)
            ans[t[po]] = get(q[t[po]].S)-get(q[t[po]].F-1),po++ ;
    }
    for(ll y= 0 ; y < Q ; y++)
        cout<<ans[y]<<endl;

}


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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;

const int N = 2e5 + 2;
const int M = 1e6 + 2;
const int mod = 998244353;
const int inf = 2e9 + 3;
const ll INF = 1e16;

/*
	BIN POISK EBANA V ROT
	DP EBANA V ROT
	DO EBANA V ROT
*/

int n, m, a[N], pos[N];
ll ans[N];
vpii L[N], R[N];

struct tree {
	ll t[M] = {0};

	void build(int v = 1, int tl = 1, int tr = n) {
		if (tl == tr) {
			t[v] = 0;
			return;
		}
		int tm = tl + tr >> 1;
		build(v * 2, tl, tm);
		build(v * 2 + 1, tm + 1, tr);
		t[v] = t[v * 2] + t[v * 2 + 1];
	}

	void upd(int pos, int v = 1, int tl = 1, int tr = n) {
		if (tl == tr) {
			t[v]++;
			return;
		}
		int tm = tl + tr >> 1;
		if (pos <= tm)
			upd(pos, v * 2, tl, tm);
		else
			upd(pos, v * 2 + 1, tm + 1, tr);
		t[v] = t[v * 2] + t[v * 2 + 1];
	}

	ll get(int l, int r, int v = 1, int tl = 1, int tr = n) {
		if (l <= tl && tr <= r)
			return t[v];
		if (tr < l || r < tl)
			return 0;
		int tm = tl + tr >> 1;
		return get(l, r, v * 2, tl, tm) + get(l, r, v * 2 + 1, tm + 1, tr);
	}
} t;

int main() {
	scanf("%d %d", &n, &m);
	for (int i =1; i <= n; ++i) {
		scanf("%d", &a[i]);
		pos[a[i]] = i;
	}
	for (int i = 1, l, r; i <= m; ++i) {
		scanf("%d %d", &l, &r);
		L[l].pb({r, i});
		R[r].pb({l, i});
	}
	t.build();
	for (int i =1; i <= n; ++i) {
		for (int j = 2 * a[i]; j <= n; j += a[i]) {
			if (pos[j] <= i)
				t.upd(pos[j]);
		}
		for (auto it : R[i]) {
			ans[it.S] += t.get(it.F, i);
		}
	}
	t.build();
	for (int i =n; i >= 1; --i) {
		for (int j = a[i]; j <= n; j += a[i]) {
			if (pos[j] >= i)
				t.upd(pos[j]);
		}
		for (auto it : L[i]) {
			ans[it.S] += t.get(i, it.F);
		}
	}
	for (int i = 1; i <= m; ++i)
		printf("%lld\n", ans[i]);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/


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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;

const int N = 2e5 + 2;
const int M = 1e6 + 2;
const int mod = 998244353;
const int inf = 2e9 + 3;
const ll INF = 1e16;

/*
	BIN POISK EBANA V ROT
	DP EBANA V ROT
	DO EBANA V ROT
*/

int n, m, a[N], pos[N];
ll ans[N];
vpii L[N], R[N];

struct tree {
	ll t[N] = {0};

	void build() {
		for (int i = 0; i <= n; ++i)
			t[i] = 0;
	}

	void upd(int a) {
		for (; a <= 200000; a += (a & -a))
			t[a]++;
	}

	int teg(int a) {
		int b = 0;
		for (; a > 0; a -= (a & -a))
			b += t[a];
		return b;
	}

	int get(int a, int b)  {
		return teg(b) - teg(a - 1);
	}
} t;

int main() {
	scanf("%d %d", &n, &m);
	for (int i =1; i <= n; ++i) {
		scanf("%d", &a[i]);
		pos[a[i]] = i;
	}
	for (int i = 1, l, r; i <= m; ++i) {
		scanf("%d %d", &l, &r);
		L[l].pb({r, i});
		R[r].pb({l, i});
	}
	t.build();
	for (int i =1; i <= n; ++i) {
		for (int j = 2 * a[i]; j <= n; j += a[i]) {
			if (pos[j] <= i)
				t.upd(pos[j]);
		}
		for (auto it : R[i]) {
			ans[it.S] += t.get(it.F, i);
		}
	}
	t.build();
	for (int i =n; i >= 1; --i) {
		for (int j = a[i]; j <= n; j += a[i]) {
			if (pos[j] >= i)
				t.upd(pos[j]);
		}
		for (auto it : L[i]) {
			ans[it.S] += t.get(i, it.F);
		}
	}
	for (int i = 1; i <= m; ++i)
		printf("%lld\n", ans[i]);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;

int n, m;
int a[MAXN], b[MAXN];
int l[MAXN], r[MAXN];
int sum[MAXN];
int ans[MAXN];
vector<int> li[MAXN], ri[MAXN];

void add(int x) {
    for(int i = x; i <= n; i += (i & -i)) sum[i]++;
}

int ask(int x) {
    int res = 0;
    for(int i = x; i >= 1; i -= (i & -i)) res += sum[i];
    return res;
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]), b[a[i]] = i;
    for(int i = 1; i <= m; i++) {
        scanf("%d%d", &l[i], &r[i]);
        li[l[i]].push_back(i);
        ri[r[i]].push_back(i);
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < li[i].size(); j++) ans[li[i][j]] -= ask(r[li[i][j]]) - ask(i - 1);
        for(int j = 1; j * a[i] <= n; j++) add(b[j * a[i]]);
        for(int j = 0; j < ri[i].size(); j++) ans[ri[i][j]] += ask(i) - ask(l[ri[i][j]] - 1);
    }
    for(int i = 1; i <= m; i++) cout << ans[i] << endl;
    return 0;
}


#include<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
const int maxm=2e5+5;
int a[maxm];
int pos[maxm];
int l[maxm],r[maxm];
int c[maxm];
int n;
struct Node{
    int l,r,id;
    bool operator<(const Node a)const{
        return l<a.l;
    }
}q[maxm],qq[maxm];
int res[maxm];
int lowbit(int i){
    return i&-i;
}
void add(int i,int t){
    while(i<=n){
        c[i]+=t;
        i+=lowbit(i);
    }
}
int ask(int i){
    int ans=0;
    while(i){
        ans+=c[i];
        i-=lowbit(i);
    }
    return ans;
}
signed main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        pos[a[i]]=i;
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d",&q[i].l,&q[i].r);
        qq[i].l=q[i].r,qq[i].r=q[i].l;
        q[i].id=qq[i].id=i;
    }
    sort(q+1,q+1+m);
    sort(qq+1,qq+1+m);
    for(int i=1,j=1,k=1;i<=n;i++){
        while(j<=m&&q[j].l==i){
            res[q[j].id]-=ask(q[j].r)-ask(q[j].l-1);
            j++;
        }
        for(int p=a[i];p<=n;p+=a[i]){
            add(pos[p],1);
        }
        while(k<=m&&qq[k].l==i){
            res[qq[k].id]+=ask(qq[k].l)-ask(qq[k].r-1);
            k++;
        }
    }
    for(int i=1;i<=m;i++){
        printf("%d\n",res[i]);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxm=2e5+5;
int a[maxm];
int pos[maxm];
int c[maxm];
int res[maxm];
int l[maxm],r[maxm];
int n,m;
vector<int>L[maxm],R[maxm];
int lowbit(int i){
    return i&-i;
}
void add(int i,int t){
    while(i<=n){
        c[i]+=t;
        i+=lowbit(i);
    }
}
int ask(int i){
    int ans=0;
    while(i){
        ans+=c[i];
        i-=lowbit(i);
    }
    return ans;
}
signed main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        pos[a[i]]=i;
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d",&l[i],&r[i]);
        L[l[i]].push_back(i);
        R[r[i]].push_back(i);
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<(int)L[i].size();j++){
            res[L[i][j]]-=ask(r[L[i][j]])-ask(i-1);
        }
        for(int j=a[i];j<=n;j+=a[i]){
            add(pos[j],1);
        }
        for(int j=0;j<(int)R[i].size();j++){
            res[R[i][j]]+=ask(i)-ask(l[R[i][j]]-1);
        }
    }
    for(int i=1;i<=m;i++){
        printf("%d\n",res[i]);
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 200010;

int a[MAXN], pos[MAXN], tree[MAXN];
int n, m;

int lowbit(int x) {
    return x & (-x);
}

int get_sum(int k) {
    int ans = 0;
    while(k > 0) {
        ans += tree[k];
        k -= lowbit(k);
    }
    return ans;
}

void modify(int k, int val) {
    while(k <= n) {
        tree[k] += val;
        k += lowbit(k);
    }
}

struct QUERY {
    int id, L, R;
    bool operator < (const QUERY &rhs) const {
        return L < rhs.L;
    }
} query[MAXN], query_t[MAXN];

int ans[MAXN];

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        pos[a[i]] = i;
    }
    for(int i = 1; i <= m; ++i) {
        scanf("%d%d", &query[i].L, &query[i].R);
        query_t[i].L = query[i].R;
        query_t[i].R = query[i].L;
        query[i].id = query_t[i].id = i;
    }
    sort(query + 1, query + m + 1);
    sort(query_t + 1, query_t + m + 1);
    for(int i = 1, j = 1, k = 1; i <= n; ++i) {
        while(j <= m && query[j].L == i) {
            ans[query[j].id] -= get_sum(query[j].R) - get_sum(query[j].L - 1);
            ++j;
        }
        for(int p = a[i]; p <= n; p += a[i]) modify(pos[p], 1);
        while(k <= m && query_t[k].L == i) {
            ans[query_t[k].id] += get_sum(query_t[k].L) - get_sum(query_t[k].R - 1);
            ++k;
        }
    }
    for(int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
}


#include<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxm=2e5+5;
int a[maxm];
int pos[maxm];
int c[maxm];
int res[maxm];
int l[maxm],r[maxm];
int n,m;
vector<int>L[maxm],R[maxm];
int lowbit(int i){
    return i&-i;
}
void add(int i){
    while(i<=n){
        c[i]++;
        i+=lowbit(i);
    }
}
int ask(int i){
    int ans=0;
    while(i){
        ans+=c[i];
        i-=lowbit(i);
    }
    return ans;
}
signed main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        pos[a[i]]=i;
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d",&l[i],&r[i]);
        L[l[i]].push_back(i);
        R[r[i]].push_back(i);
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<(int)L[i].size();j++){
            res[L[i][j]]-=ask(r[L[i][j]])-ask(i-1);
        }
        for(int j=a[i];j<=n;j+=a[i]){
            add(pos[j]);
        }
        for(int j=0;j<(int)R[i].size();j++){
            res[R[i][j]]+=ask(i)-ask(l[R[i][j]]-1);
        }
    }
    for(int i=1;i<=m;i++){
        printf("%d\n",res[i]);
    }
    return 0;
}


#include <bits/stdc++.h>

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, m, a[maxN], pos[maxN];
vi divisors[maxN];

struct query
{
    int l, r, idx;
    ll res;
    query() {}
    query(int l, int r, int idx) : l(l), r(r), idx(idx) {}
};

vector <query> q;

ll f[maxN];

void update(int x, ll d)
{
    for (; x <= n; x += x & -x)
    {
        f[x] += d;
    }
}

ll prefix(int x)
{
    ll r = 0;
    for (; x > 0; x &= x - 1)
    {
        r += f[x];
    }
    return r;
}

void init()
{
    for1(i, 2e5)
    {
        for (int j = i; j <= 2e5; j += i)
        {
            divisors[j].eb(i);
        }
    }
}

void solve()
{
    init();
    cin >> n >> m;
    for1(i, n)
    {
        cin >> a[i];
        pos[a[i]] = i;
    }
    for1(i, m)
    {
        int l, r;
        cin >> l >> r;
        q.eb(l, r, i);
    }
    sort(all(q), [](query x, query y)
         {
             return x.r < y.r;
         });
    int idx = 0;
    for1(i, n)
    {
        for (auto &d: divisors[a[i]])
        {
            update(pos[d], 1);
        }
        while (idx < m && q[idx].r <= i)
        {
            q[idx].res = prefix(q[idx].r) - prefix(q[idx].l - 1);
            ++idx;
        }
    }
    sort(all(q), [](query x, query y)
         {
             return x.idx < y.idx;
         });
    for (auto &qr: q)
    {
        cout << qr.res << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, m, a[maxN], pos[maxN];
vi divisors[maxN], multiples[maxN];

struct query
{
    int l, r, idx;
    ll res;
    query() {}
    query(int l, int r, int idx) : l(l), r(r), idx(idx) {}
};

vector <query> q;

ll f[maxN];

void update(int x, ll d)
{
    for (; x <= n; x += x & -x)
    {
        f[x] += d;
    }
}

ll prefix(int x)
{
    ll r = 0;
    for (; x > 0; x &= x - 1)
    {
        r += f[x];
    }
    return r;
}

void init()
{
    for1(i, n)
    {
        for (int j = i; j <= n; j += i)
        {
            divisors[j].eb(i);
            multiples[i].eb(j);
        }
    }
    for1(i, n)
    {
        sort(all(divisors[i]));
        sort(all(multiples[i]));
    }
}

void solve()
{
    cin >> n >> m;
    init();
    for1(i, n)
    {
        cin >> a[i];
        pos[a[i]] = i;
    }
    for1(i, m)
    {
        int l, r;
        cin >> l >> r;
        q.eb(l, r, i);
    }
    sort(all(q), [](query x, query y)
         {
             return x.r < y.r;
         });
    int idx = 0;
    for1(i, n)
    {
        for (auto &div: divisors[a[i]])
        {
            if (pos[div] <= i)
            {
                update(pos[div], 1);
            }
        }
        for (auto &mul: multiples[a[i]])
        {
            if (pos[mul] < i)
            {
                update(pos[mul], 1);
            }
        }
        while (idx < m && q[idx].r <= i)
        {
            q[idx].res = prefix(q[idx].r) - prefix(q[idx].l - 1);
            ++idx;
        }
    }
    sort(all(q), [](query x, query y)
         {
             return x.idx < y.idx;
         });
    for (auto &qr: q)
    {
        cout << qr.res << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, m, a[maxN], pos[maxN];
vi divisors[maxN], multiples[maxN];

struct query
{
    int l, r, idx;
    ll res;
    query() {}
    query(int l, int r, int idx) : l(l), r(r), idx(idx) {}
};

vector <query> q;

ll f[maxN];

void update(int x, ll d)
{
    for (; x <= n; x += x & -x)
    {
        f[x] += d;
    }
}

ll prefix(int x)
{
    ll r = 0;
    for (; x > 0; x &= x - 1)
    {
        r += f[x];
    }
    return r;
}

void init()
{
    for1(i, n)
    {
        for (int j = i; j <= n; j += i)
        {
            divisors[j].eb(i);
            multiples[i].eb(j);
        }
    }
    for1(i, n)
    {
        sort(all(divisors[i]), [&](int x, int y)
             {
                 return pos[x] < pos[y];
             });
        sort(all(multiples[i]), [&](int x, int y)
             {
                 return pos[x] < pos[y];
             });
    }
}

void solve()
{
    cin >> n >> m;
    for1(i, n)
    {
        cin >> a[i];
        pos[a[i]] = i;
    }
    init();
    for1(i, m)
    {
        int l, r;
        cin >> l >> r;
        q.eb(l, r, i);
    }
    sort(all(q), [](query x, query y)
         {
             return x.r < y.r;
         });
    int idx = 0;
    for1(i, n)
    {
        for (auto &div: divisors[a[i]])
        {
            if (pos[div] <= i)
            {
                update(pos[div], 1);
            }
        }
        for (auto &mul: multiples[a[i]])
        {
            if (pos[mul] < i)
            {
                update(pos[mul], 1);
            }
        }
        while (idx < m && q[idx].r <= i)
        {
            q[idx].res = prefix(q[idx].r) - prefix(q[idx].l - 1);
            ++idx;
        }
    }
    sort(all(q), [](query x, query y)
         {
             return x.idx < y.idx;
         });
    for (auto &qr: q)
    {
        cout << qr.res << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, m, a[maxN], pos[maxN];
vi divisors[maxN], multiples[maxN];

struct query
{
    int l, r, idx;
    ll res;
    query() {}
    query(int l, int r, int idx) : l(l), r(r), idx(idx) {}
};

vector <query> q;

ll f[maxN];

void update(int x, ll d)
{
    for (; x <= n; x += x & -x)
    {
        f[x] += d;
    }
}

ll prefix(int x)
{
    ll r = 0;
    for (; x > 0; x &= x - 1)
    {
        r += f[x];
    }
    return r;
}

void init()
{
    for1(i, n)
    {
        for (int j = i; j <= n; j += i)
        {
            divisors[j].eb(i);
            multiples[i].eb(j);
        }
    }
    for1(i, n)
    {
        for (auto &div: divisors[i])
        {
            div = pos[div];
        }
        for (auto &mul: multiples[i])
        {
            mul = pos[mul];
        }
        sort(all(divisors[i]));
        sort(all(multiples[i]));
    }
}

void solve()
{
    cin >> n >> m;
    for1(i, n)
    {
        cin >> a[i];
        pos[a[i]] = i;
    }
    init();
    for1(i, m)
    {
        int l, r;
        cin >> l >> r;
        q.eb(l, r, i);
    }
    sort(all(q), [](query x, query y)
         {
             return x.r < y.r;
         });
    int idx = 0;
    for1(i, n)
    {
        for (auto &div: divisors[a[i]])
        {
            if (div <= i)
            {
                update(div, 1);
            }
        }
        for (auto &mul: multiples[a[i]])
        {
            if (mul < i)
            {
                update(mul, 1);
            }
        }
        while (idx < m && q[idx].r <= i)
        {
            q[idx].res = prefix(q[idx].r) - prefix(q[idx].l - 1);
            ++idx;
        }
    }
    sort(all(q), [](query x, query y)
         {
             return x.idx < y.idx;
         });
    for (auto &qr: q)
    {
        cout << qr.res << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, m, a[maxN], pos[maxN];
vi divisors[maxN], multiples[maxN];

struct query
{
    int l, r, idx;
    ll res;
    query() {}
    query(int l, int r, int idx) : l(l), r(r), idx(idx) {}
};

vector <query> q;

ll f[maxN];

void update(int x, ll d)
{
    for (; x <= n; x += x & -x)
    {
        f[x] += d;
    }
}

ll prefix(int x)
{
    ll r = 0;
    for (; x > 0; x &= x - 1)
    {
        r += f[x];
    }
    return r;
}

void init()
{
    for1(i, n)
    {
        for (int j = i; j <= n; j += i)
        {
            divisors[j].eb(i);
            multiples[i].eb(j);
        }
    }
    for1(i, n)
    {
        for (auto &div: divisors[i])
        {
            div = pos[div];
        }
        for (auto &mul: multiples[i])
        {
            mul = pos[mul];
        }
        sort(all(divisors[i]));
        sort(all(multiples[i]));
    }
}

void solve()
{
    cin >> n >> m;
    for1(i, n)
    {
        cin >> a[i];
        pos[a[i]] = i;
    }
    init();
    for1(i, m)
    {
        int l, r;
        cin >> l >> r;
        q.eb(l, r, i);
    }
    sort(all(q), [](query x, query y)
         {
             return x.r < y.r;
         });
    int idx = 0;
    for1(i, n)
    {
        for (auto &div: divisors[a[i]])
        {
            if (div <= i)
            {
                update(div, 1);
            }
            else
            {
                break;
            }
        }
        for (auto &mul: multiples[a[i]])
        {
            if (mul < i)
            {
                update(mul, 1);
            }
            else
            {
                break;
            }
        }
        while (idx < m && q[idx].r <= i)
        {
            q[idx].res = prefix(q[idx].r) - prefix(q[idx].l - 1);
            ++idx;
        }
    }
    sort(all(q), [](query x, query y)
         {
             return x.idx < y.idx;
         });
    for (auto &qr: q)
    {
        cout << qr.res << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, m, a[maxN], pos[maxN];
vi divisors[maxN], multiples[maxN];

struct query
{
    int l, r, idx;
    ll res;
    query() {}
    query(int l, int r, int idx) : l(l), r(r), idx(idx) {}
};

vector <query> q;

ll f[maxN];

void update(int x, ll d)
{
    for (; x <= n; x += x & -x)
    {
        f[x] += d;
    }
}

ll prefix(int x)
{
    ll r = 0;
    for (; x > 0; x &= x - 1)
    {
        r += f[x];
    }
    return r;
}

void init()
{
    for1(i, n)
    {
        for (int j = i; j <= n; j += i)
        {
            divisors[j].eb(i);
            multiples[i].eb(j);
        }
    }
    for1(i, n)
    {
        sort(all(divisors[i]), [](int x, int y)
             {
                 return pos[x] < pos[y];
             });
        sort(all(multiples[i]), [](int x, int y)
             {
                 return pos[x] < pos[y];
             });
    }
}

void solve()
{
    cin >> n >> m;
    for1(i, n)
    {
        cin >> a[i];
        pos[a[i]] = i;
    }
    init();
    for1(i, m)
    {
        int l, r;
        cin >> l >> r;
        q.eb(l, r, i);
    }
    sort(all(q), [](query x, query y)
         {
             return x.r < y.r;
         });
    int idx = 0;
    for1(i, n)
    {
        for (auto &div: divisors[a[i]])
        {
            if (pos[div] <= i)
            {
                update(pos[div], 1);
            }
        }
        for (auto &mul: multiples[a[i]])
        {
            if (pos[mul] < i)
            {
                update(pos[mul], 1);
            }
        }
        while (idx < m && q[idx].r <= i)
        {
            q[idx].res = prefix(q[idx].r) - prefix(q[idx].l - 1);
            ++idx;
        }
    }
    sort(all(q), [](query x, query y)
         {
             return x.idx < y.idx;
         });
    for (auto &qr: q)
    {
        cout << qr.res << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, m, a[maxN], pos[maxN];
vi divisors[maxN], multiples[maxN];

struct query
{
    int l, r, idx;
    ll res;
    query() {}
    query(int l, int r, int idx) : l(l), r(r), idx(idx) {}
};

vector <query> q;

ll f[maxN];

void update(int x, ll d)
{
    for (; x <= n; x += x & -x)
    {
        f[x] += d;
    }
}

ll prefix(int x)
{
    ll r = 0;
    for (; x > 0; x &= x - 1)
    {
        r += f[x];
    }
    return r;
}

void init()
{
    for1(i, n)
    {
        for (int j = i; j <= n; j += i)
        {
            divisors[j].eb(i);
            multiples[i].eb(j);
        }
    }
    for1(i, n)
    {
        for (auto &div: divisors[i])
        {
            div = pos[div];
        }
        for (auto &mul: multiples[i])
        {
            mul = pos[mul];
        }
        sort(all(divisors[i]));
        sort(all(multiples[i]));
    }
}

void solve()
{
    cin >> n >> m;
    for1(i, n)
    {
        cin >> a[i];
        pos[a[i]] = i;
    }
    init();
    for1(i, m)
    {
        int l, r;
        cin >> l >> r;
        q.eb(l, r, i);
    }
    sort(all(q), [](query x, query y)
         {
             return x.r < y.r;
         });
    int idx = 0;
    for1(i, n)
    {
        for (auto &div: divisors[a[i]])
        {
            if (div <= i)
            {
                update(div, 1);
            }
            else
            {
                break;
            }
        }
        for (auto &mul: multiples[a[i]])
        {
            if (mul < i)
            {
                update(mul, 1);
            }
            else
            {
                break;
            }
        }
        while (idx < m && q[idx].r <= i)
        {
            q[idx].res = prefix(q[idx].r) - prefix(q[idx].l - 1);
            ++idx;
        }
    }
    sort(all(q), [](query x, query y)
         {
             return x.idx < y.idx;
         });
    for (auto &qr: q)
    {
        cout << qr.res << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--)
    {
        solve();
    }
    return 0;
}


#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int G = 200005;
int a,z, ps[G], BIT[G], c;
vec<int> rg[G];
map<pii, int> mp;
pii que[G], st[G];

void add(int p, int val){
    for(; p<G; p += p&-p) BIT[p] += val;
}

int prs(int p){
    int o = 0;
    for(; p>0; p -= p&-p) o += BIT[p];
    return o;
}

int main() {
    fast;
    memset(BIT, 0, sizeof(BIT));
    cin>>a>>z;
    for(int q=0; q<a; q++) cin>>c, ps[c] = q+1;
    for(int q=1; q<=a; q++) for(int w=q; w<=a; w+=q) rg[min(ps[q], ps[w])].pb(max(ps[q], ps[w]));
    for(int q=0; q<z; q++) cin>>que[q].F>>que[q].S;
    memcpy(st, que, sizeof(st));
    sort(que, que+z);
    for(int q=z-1, l=a+1; q>=0; q--){
        for(; l>que[q].F; l--) for(int i : rg[l-1]) add(i, 1);
        mp[que[q]] = prs(que[q].S)-prs(que[q].F-1);
    }
    for(int q=0; q<z; q++) cout<<mp[st[q]]<<"\n";
}