local mfl = math.floor
local n = io.read("*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
local curbits = {}
for i = 1, 20 do curbits[i] = 0 end

local function add(idx)
  local v = a[idx]
  for i = 1, 20 do
    curbits[i] = curbits[i] + v % 2
    v = mfl(v / 2)
  end
end

local function rm(idx)
  local v = a[idx]
  for i = 1, 20 do
    curbits[i] = curbits[i] - v % 2
    v = mfl(v / 2)
  end
end

local function check()
  for i = 1, 20 do if 1 < curbits[i] then return false end end
  return true
end

local left, right = 1, 1
local ret = 0
while right <= n do
  add(right)
  if check() then
    ret = ret + right + 1 - left
  else
    while left < right do
      rm(left)
      left = left + 1
      if check() then
        ret = ret + right + 1 - left
        break
      end
    end
  end
  right = right + 1
end
print(ret)
