// Arup Guha
// 4/2/2024
// Solution to Kattis Problem: Nikola
// https://open.kattis.com/problems/nikola

import java.util.*;

public class nikola {

	public static int n;
	public static int[] cost;
	public static int[][] memo;
	
	public static void main(String[] args) {
	
		// Get costs.
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		cost = new int[n];
		for (int i=0; i<n; i++)
			cost[i] = stdin.nextInt();
			
		// Set up memo.
		memo = new int[n][n];
		for (int i=0; i<n; i++)
			Arrays.fill(memo[i], -1);
			
		// Ta da!
		System.out.println(go(0, 0));
	}
	
	// Returns min cost to goal from location loc, given that the previous jump was prev.
	public static int go(int loc, int prev) {
	
		// Our base cases.
		if (loc == n-1) return 0;
		if (memo[loc][prev] != -1) return memo[loc][prev];
		
		// This is safe, cost will never be this high.
		int res = 1000000000;
		
		// Try going forward, cost is cost for entering square plus the min cost of the rest of the path.
		if (loc+prev+1 < n)
			res = Math.min(res, cost[loc+prev+1]+go(loc+prev+1, prev+1));
	
		// Try going backwards.
		if (loc-prev >= 0 && prev > 0)
			res = Math.min(res, cost[loc-prev] + go(loc-prev, prev));
			
		// Store and return.
		return memo[loc][prev] = res;
	}

}