'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = input.shift() - 0
  input = input[0].split(' ')
  let a = {}
  let b = {}
  let count = [0, 0]
  for (let i = 0; i < N; i++) {
    if (i%2) {
      let num = input[i] - 0
      if (!(num in a)) {
        a[num] = 0
        count[0]++
      }
      a[num]++
    } else {
      let num = input[i] - 0
      if (!(num in b)) {
        b[num] = 0
        count[1]++
      }
      b[num]++
    }
  }

  const newArr = [
    ...(Object.keys(a).map(v => [v, a[v], 0])),
    ...(Object.keys(b).map(v => [v, b[v], 1]))
  ].sort((a, b) => b[1] - a[1])
  // console.log(newArr)
  let ans = 0
  let selected = [['', 0, 0], ['', 0, 0]]
  newArr.forEach((a, i) => {
    const s = a[2]
    const o = Math.abs(s-1)
    if (selected[s][1] === 0 && selected[o][0] !== a[0]) {
      selected[s] = [...a]
    } else {
      if (selected[o][0] === a[0]) {
        for (let j = i; j < count[o]; j++) {
          if (newArr[j][2] === o) {
            if (newArr[j][1] >= a[1]) {
              selected[s] = [...a]
              selected[o] = ['', 0, 0]
            }
            break;
          }
        }
      }
      ans += a[1]
    }
  })

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
