import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A = new Array[Int](N+2)

  for(i <- 1 to N)
    A(i) = in.next().toInt


  //
  var l = 1; var r = 1
  var now = A(1).toBinaryString
  var ans = 0L
  var bits = new Array[Boolean](21)

  def debug(): Unit = {
    val hoge = bits.map { x =>
      if(x) "1" else "0"
    }.mkString("").reverse
    println(hoge)
  }

  def check(_now: String): Boolean = {
    val now = _now.reverse
    var res = true
    for(i <- 0 until now.length) {
      if(now(i) == '1' && bits(i))
        res = false
    }

    res
  }

  def add(_bit: String): Unit = {
    val bit = _bit.reverse
    for(i <- 0 until bit.length) {
      if(bit(i) == '1')
        bits(i) = true
    }
  }

  def sub(_bit: String): Unit = {
    val bit = _bit.reverse
    for(i <- 0 until bit.length) {
      if(bit(i) == '1')
        bits(i) = false
    }
  }

  //
  while(r <= N) {
    // println(l, r)
    // debug()


    if(check(now)) {
      add(now)
      r += 1
      now = A(r).toBinaryString
    }
    else {
      // println(l, r)
      ans += r - l
      sub(A(l).toBinaryString)
      l += 1
    }
  }


  // 最後の処理
  while(l <= N){
    ans += (N + 1 - l)
    l += 1
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

