function Main(input) {
	let tempArr = input.split('\n')
    let targetArr = tempArr[1].split(' ')
    let positionsArr = tempArr.splice(2,tempArr.length-1)
    for(let i=0;i<positionsArr.length;i++){
    	let arr = positionsArr[i].split(' ')
        let x = Number(arr[0])
        let y = Number(arr[1])
      	let tempArr1 = targetArr.slice(x-1,y)
        
      	let tempArr2 = tempArr1.filter((v,i) => tempArr1.indexOf(v) === i)
        console.log(tempArr2.length)
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));