'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift();
  var counter=0;
  var head=0;
  var body=0;
  var tail=0;
  var value=0;
  while(head<N){
    if(value&input[head]){
      counter+=(body-tail)*(head-body)+(head-body)*(head-body+1)/2;
      body=head;
      while(value&input[head]){
        value^=input[tail];
        tail++;
      }
    }else{
      value|=input[head];
      head++;
    }
  }
  counter+=(body-tail)*(head-body)+(head-body)*(head-body+1)/2;
  console.log(counter);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));