
object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val numbers = readLine.trim.split(' ').map(_.toInt).sorted
  val isSearched = Array.tabulate(n){i ⇒ Array.tabulate(n - i){_ ⇒ false}}
  var max = 0
  for (i ← 0 until n; j ← i + 1 until n){
    val len = search(i, numbers(j))
    if (len > max) max = len
  }
  println(max)
  def search(init: Int, next: Int): Int = {
    val pos = lowerBound(numbers, next)
    if (numbers(pos) != next) 1
    else {
      if (isSearched(init)(pos - init)) 1
      else {
        isSearched(init)(pos - init) = true
        search(pos, next - numbers(init) + next) + 1
      }
    }
  }
  @inline
  def lowerBound(array: Array[Int], target: Int): Int = {
    var left = 0
    var right = array.length - 1
    while(left < right){
      if (array((left + right) / 2) < target) {
        left = (left + right) / 2 + 1
      }else {
        right = (left + right) / 2
      }
    }
    right
  }

  implicit class Scope[T](val value: T) extends AnyVal{
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](func: T ⇒ A): A = func(value)

  }
}

