import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

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

  val N = in.next().toInt
  val s = new Array[Int](N)
  for (i <- 0 until N)
    s(i) = in.next().toInt


  //
  var ans = 0L
  for (c <- 1 to N-2) { // c := A - B
    var score = 0L

    val dp = new Array[Boolean](N)
    dp(0) = true; dp(N-1) = true

    var x = 1
    breakable {
      while (true) {
        if (x*c >= N)
          break

        if (dp(x*c))
          break
        dp(x*c) = true

        if (dp((N-1)-x*c))
          break
        dp((N-1)-x*c) = true

        score += s(x*c)
        score += s((N-1)-x*c)

        ans = Math.max(ans, score)

        x += 1
      }
    }
  }

  println(ans)
}


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

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}
