#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
const int maxn = 50005;
typedef long long ll;
ll c[maxn];
ll sum[maxn];
struct node{
ll l,r,num;
}q[maxn];
ll anss[maxn];
ll block;
ll ans = 0;
bool cmp(const node &a,const node &b){
return (a.r/block)==(b.r/block)?a.l<b.l:a.r<b.r;
}
void del(int x){
sum[c[x]]--;
ans-=2*sum[c[x]]+1;
}
void add(int x){
sum[c[x]]++;
ans+=2*sum[c[x]]-1;
}
int main(){
ll n,m,k;
scanf("%lld%lld%lld",&n,&m,&k);
block=sqrt(n);
for(int i =1;i<=n;++i){
scanf("%lld",&c[i]);
}
for(int i =1;i<=m;++i){
scanf("%lld%lld",&q[i].l,&q[i].r);
q[i].num=i;
}
sort(q+1,q+1+m,cmp);
int l=1,r=0;
for(int i =1;i<=m;++i){
ll ql=q[i].l,qr=q[i].r;
while(l<ql){
del(l);
l++;
}
while(l>ql){
l--;
add(l);
}
while(r<qr){
r++;
add(r);
}
while(r>qr){
del(r);
r--;
}
anss[q[i].num]=ans;
}
for(int i =1;i<=m;++i){
printf("%lld\n",anss[i]);
}
return 0;
}