var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	input = input.map(e => toIntArr(e.split(' ')));
	var n = input[0][0];
	var as = input[1];
	var ans = 0;
	var bits = [1];
	for(var i = 1; i < 32; i++){
		bits[i] = bits[i-1]*2;
	}
	function getBits(num){
		var num = num;
		var arr = [];
		var temp;
		for(var i = 0; i < 30; i++){
			temp = num % 2;
			arr[i] = temp;
			num = (num-temp)/2;
		}
		return arr;
	}

	var abcd;
	var asObj = {}
	var getObj = {};
	var rev = [];
	var a;
	var flag;
	var flag2;
	var b,c,d;
	var get;
	var rev;

	for(var i = 0; i < n; i++){
		abcd = [];
		a = as[i]
		flag = 0;
		flag2 = 0;

		if(asObj[a]===undefined){
			asObj[a] = 1;
		}else{
			asObj[a]++;
		}

		a = getBits(a);

		for(var j = 0; j < 30; j++){
			b = a[30-j-1];
			if(flag === 0){
				if(b===1){
					flag++;
					abcd[0] = j;
				}
			}else if(flag===1){
				if(b===0){
					flag++;
					abcd[1] = j-abcd[0];
				}
			}
			c = a[j];
			if(flag2===0){
				if(c===1){
					flag2++;
					abcd[3] = j;
				}
			}
		}

		abcd[2] = 30 - abcd[0] - abcd[1] - abcd[3];

		d = abcd[3];
		c = abcd[2];
		get = bits[d];
		rev = get;
		for(var k = d+1; k < c+d; k++){
			get += bits[k]*a[k];
			rev += bits[k]*(1-a[k]);
		}
		if(getObj[get]===undefined){
			getObj[get] = [1,rev];
		}else{
			if(rev === getObj[get][1]){
				getObj[get][0]++;
			}else{
				if(getObj[-get]===undefined){
					getObj[-get] = [1,rev];
				}else{
					getObj[-get][0]++;
				}
			}
		}

	}

	var ans = 0;
	var x,y,z;
	for(var prop in getObj){
		x = getObj[prop][0];
		y = getObj[prop][1];
		z = asObj[y];
		if(prop<0)prop*=-1;
		if(z===undefined) z = 0;
		if(prop == y || (prop == 0 && y === 1)) x--;
		ans += max(0,min(x,z));
	}
	//console.log(getObj,asObj)
	console.log(ans);
}