import itertools
import math
import sys
from collections import defaultdict

def is_debug():
    return '--debug' in sys.argv

def stdin_wrapper():
    data = '''6
0
1 1 2 2 3 3 3 3 3 3
0
1 1 2 2 3 3
5
1 2 2 1 3
3
1 1 1
4
1 1000 101 1000
4
1 2 3 4

'''

    for line in data.split('\n'):
        yield line

if not is_debug():
    def stdin_wrapper():
        while True:
            yield sys.stdin.readline()

inputs = stdin_wrapper()

def input_wrapper():
    return next(inputs)

def get_str():
    if is_debug():
        return input_wrapper()

    return input()

def get(_type):
    if _type == str:
        return get_str()

    return _type(input_wrapper())

def get_arr(_type):
    return [_type(x) for x in input_wrapper().split()]

def tuplerize(method):
    def wrap(*args, **kwargs):
        res = method(*args, **kwargs)
        if not isinstance(res, (tuple, list)):
            res = (res, )

        return res
    return wrap

''' Solution '''
@tuplerize
def solve(nodes):
    chain = []

    node_info = defaultdict(list)
    for i in range(len(nodes)):
        node_info[nodes[i]].append(i+1)

    node_info = sorted(list(node_info.items()), key=lambda v: len(v[1]))[::-1]
    poses = [0 for _ in range(len(node_info))]
    current = 0
    skipped = 0

    last_added = None
    while True:
        if poses[current] >= len(node_info[current][1]) or last_added == current:
            skipped += 1
            if skipped == len(poses):
                break

            continue
        skipped = 0

        chain.append(node_info[current][1][poses[current]])
        last_added = current
        poses[current] += 1
        current = (current + 1) % len(poses)

    if len(chain) != len(nodes):
        return 'NO'

    result = ['YES']
    for i in range(len(chain)-1):
        result.append('{} {}'.format(chain[i], chain[i+1]))

    return '\n'.join(result)

    # _max_len = max([len(node_info[x]) for x in node_info])
    # current_group = 0
    # for x in node_info:
    #     if len(node_info[x]) == _max_len:
    #         current_group = x
    #         break

    # result = []
    # while node_info:
    #     n = node_info[current_group]

    #     if not n:
    #         break

    #     current_node = n.pop()

    #     if not n:
    #         del node_info[current_group]

    #     second_group = None
    #     for x in node_info:
    #         if x != current_group:
    #             if second_group is None:
    #                 second_group = x
    #             elif len(node_info[x]) > len(node_info[second_group]):
    #                 second_group = x

    #     if second_group is None:
    #         break

    #     n_2 = node_info[second_group]

    #     if not n_2:
    #         del node_info[second_group]
    #         continue

    #     second_node = n_2[-1]

    #     result.append((current_node, second_node))

    #     current_group = second_group

    # if len(result) != (len(nodes) - 1):
    #     return 'NO'

    # return 'YES\n{}'.format('\n'.join(['{} {}'.format(*x) for x in result]))

t = get(int)
for _ in range(t):
    l = get(int)
    nodes = get_arr(int)

    print(*solve(nodes))


import itertools
import math
import sys
from collections import defaultdict

def is_debug():
    return '--debug' in sys.argv

def stdin_wrapper():
    data = '''6
0
1 1 2 2 3 3 3 3 3 3
0
1 1 2 2 3 3
5
1 2 2 1 3
3
1 1 1
4
1 1000 101 1000
4
1 2 3 4

'''

    for line in data.split('\n'):
        yield line

if not is_debug():
    def stdin_wrapper():
        while True:
            yield sys.stdin.readline()

inputs = stdin_wrapper()

def input_wrapper():
    return next(inputs)

def get_str():
    if is_debug():
        return input_wrapper()

    return input()

def get(_type):
    if _type == str:
        return get_str()

    return _type(input_wrapper())

def get_arr(_type):
    return [_type(x) for x in input_wrapper().split()]

def tuplerize(method):
    def wrap(*args, **kwargs):
        res = method(*args, **kwargs)
        if not isinstance(res, (tuple, list)):
            res = (res, )

        return res
    return wrap

''' Solution '''
@tuplerize
def solve(nodes):
    chain = []

    node_info = defaultdict(list)
    for i in range(len(nodes)):
        node_info[nodes[i]].append(i+1)

    if len(set(nodes)) == 1:
        return 'NO'

    result_lines = ['YES']
    result_edges = []
    current_group = next(iter(node_info))
    current_node = node_info[current_group].pop()
    for x in list(node_info):
        if x == current_group:
            continue

        vertices = node_info[x]
        while vertices:
            result_edges.append((current_node, vertices.pop()))
        del node_info[x]

    second = result_edges[0][1]
    while node_info[current_group]:
        result_edges.append((second, node_info[current_group].pop()))

    result_lines += ['{} {}'.format(*x) for x in result_edges]

    return '\n'.join(result_lines)

t = get(int)
for _ in range(t):
    l = get(int)
    nodes = get_arr(int)

    print(*solve(nodes))


import itertools
import math
import sys
from collections import defaultdict

def is_debug():
    return '--debug' in sys.argv

def stdin_wrapper():
    data = '''4
5
1 2 2 1 3
3
1 1 1
4
1 1000 101 1000
4
1 2 3 4

'''

    for line in data.split('\n'):
        yield line

if not is_debug():
    def stdin_wrapper():
        while True:
            yield sys.stdin.readline()

inputs = stdin_wrapper()

def input_wrapper():
    return next(inputs)

def get_str():
    if is_debug():
        return input_wrapper()

    return input()

def get(_type):
    if _type == str:
        return get_str()

    return _type(input_wrapper())

def get_arr(_type):
    return [_type(x) for x in input_wrapper().split()]

def tuplerize(method):
    def wrap(*args, **kwargs):
        res = method(*args, **kwargs)
        if not isinstance(res, (tuple, list)):
            res = (res, )

        return res
    return wrap

''' Solution '''
@tuplerize
def solve(nodes):
    node_info = defaultdict(list)
    for i in range(len(nodes)):
        node_info[nodes[i]].append(i+1)

    current_group = next(iter(node_info))
    result = []
    while node_info:

        n = node_info[current_group]

        if not n:
            break

        current_node = n.pop()

        if not n:
            del node_info[current_group]

        second_group = None
        for x in node_info:

            if x != current_group:
                second_group = x
                break

        if second_group is None:
            break

        n_2 = node_info[second_group]

        if not n_2:
            break

        second_node = n_2[-1]

        result.append((current_node, second_node))

        current_group = second_group

    if len(result) != (len(nodes) - 1):
        return 'NO'

    return 'YES\n{}'.format('\n'.join(['{} {}'.format(*x) for x in result]))

t = get(int)
for _ in range(t):
    l = get(int)
    nodes = get_arr(int)

    print(*solve(nodes))


import itertools
import math
import sys
from collections import defaultdict

def is_debug():
    return '--debug' in sys.argv

def stdin_wrapper():
    data = '''5
0
1 1 2 2 3 3
5
1 2 2 1 3
3
1 1 1
4
1 1000 101 1000
4
1 2 3 4

'''

    for line in data.split('\n'):
        yield line

if not is_debug():
    def stdin_wrapper():
        while True:
            yield sys.stdin.readline()

inputs = stdin_wrapper()

def input_wrapper():
    return next(inputs)

def get_str():
    if is_debug():
        return input_wrapper()

    return input()

def get(_type):
    if _type == str:
        return get_str()

    return _type(input_wrapper())

def get_arr(_type):
    return [_type(x) for x in input_wrapper().split()]

def tuplerize(method):
    def wrap(*args, **kwargs):
        res = method(*args, **kwargs)
        if not isinstance(res, (tuple, list)):
            res = (res, )

        return res
    return wrap

''' Solution '''
@tuplerize
def solve(nodes):
    node_info = defaultdict(list)
    for i in range(len(nodes)):
        node_info[nodes[i]].append(i+1)

    current_group = next(iter(node_info))
    result = []
    while node_info:
        n = node_info[current_group]

        if not n:
            break

        current_node = n.pop()

        if not n:
            del node_info[current_group]

        second_group = None
        for x in node_info:
            if x != current_group:
                if second_group is None:
                    second_group = x
                elif len(node_info[x]) > len(node_info[second_group]):
                    second_group = x

        if second_group is None:
            break

        n_2 = node_info[second_group]

        if not n_2:
            break

        second_node = n_2[-1]

        result.append((current_node, second_node))

        current_group = second_group

    if len(result) != (len(nodes) - 1):
        return 'NO'

    return 'YES\n{}'.format('\n'.join(['{} {}'.format(*x) for x in result]))

t = get(int)
for _ in range(t):
    l = get(int)
    nodes = get_arr(int)

    print(*solve(nodes))


import itertools
import math
import sys
from collections import defaultdict

def is_debug():
    return '--debug' in sys.argv

def stdin_wrapper():
    data = '''6
0
1 1 2 2 3 3 3 3 3
0
1 1 2 2 3 3
5
1 2 2 1 3
3
1 1 1
4
1 1000 101 1000
4
1 2 3 4

'''

    for line in data.split('\n'):
        yield line

if not is_debug():
    def stdin_wrapper():
        while True:
            yield sys.stdin.readline()

inputs = stdin_wrapper()

def input_wrapper():
    return next(inputs)

def get_str():
    if is_debug():
        return input_wrapper()

    return input()

def get(_type):
    if _type == str:
        return get_str()

    return _type(input_wrapper())

def get_arr(_type):
    return [_type(x) for x in input_wrapper().split()]

def tuplerize(method):
    def wrap(*args, **kwargs):
        res = method(*args, **kwargs)
        if not isinstance(res, (tuple, list)):
            res = (res, )

        return res
    return wrap

''' Solution '''
@tuplerize
def solve(nodes):
    node_info = defaultdict(list)
    for i in range(len(nodes)):
        node_info[nodes[i]].append(i+1)

    _max_len = max([len(node_info[x]) for x in node_info])
    current_group = 0
    for x in node_info:
        if len(node_info[x]) == _max_len:
            current_group = x
            break

    result = []
    while node_info:
        n = node_info[current_group]

        if not n:
            break

        current_node = n.pop()

        if not n:
            del node_info[current_group]

        second_group = None
        for x in node_info:
            if x != current_group:
                if second_group is None:
                    second_group = x
                elif len(node_info[x]) > len(node_info[second_group]):
                    second_group = x

        if second_group is None:
            break

        n_2 = node_info[second_group]

        if not n_2:
            break

        second_node = n_2[-1]

        result.append((current_node, second_node))

        current_group = second_group

    if len(result) != (len(nodes) - 1):
        return 'NO'

    return 'YES\n{}'.format('\n'.join(['{} {}'.format(*x) for x in result]))

t = get(int)
for _ in range(t):
    l = get(int)
    nodes = get_arr(int)

    print(*solve(nodes))


import itertools
import math
import sys
from collections import defaultdict

def is_debug():
    return '--debug' in sys.argv

def stdin_wrapper():
    data = '''6
0
1 1 2 2 2 3 3 3 3 3
0
1 1 2 2 3 3
5
1 2 2 1 3
3
1 1 1
4
1 1000 101 1000
4
1 2 3 4

'''

    for line in data.split('\n'):
        yield line

if not is_debug():
    def stdin_wrapper():
        while True:
            yield sys.stdin.readline()

inputs = stdin_wrapper()

def input_wrapper():
    return next(inputs)

def get_str():
    if is_debug():
        return input_wrapper()

    return input()

def get(_type):
    if _type == str:
        return get_str()

    return _type(input_wrapper())

def get_arr(_type):
    return [_type(x) for x in input_wrapper().split()]

def tuplerize(method):
    def wrap(*args, **kwargs):
        res = method(*args, **kwargs)
        if not isinstance(res, (tuple, list)):
            res = (res, )

        return res
    return wrap

''' Solution '''
@tuplerize
def solve(nodes):
    node_info = defaultdict(list)
    for i in range(len(nodes)):
        node_info[nodes[i]].append(i+1)

    _max_len = max([len(node_info[x]) for x in node_info])
    current_group = 0
    for x in node_info:
        if len(node_info[x]) == _max_len:
            current_group = x
            break

    result = []
    while node_info:
        n = node_info[current_group]

        if not n:
            break

        current_node = n.pop()

        if not n:
            del node_info[current_group]

        second_group = None
        for x in node_info:
            if x != current_group:
                if second_group is None:
                    second_group = x
                elif len(node_info[x]) > len(node_info[second_group]):
                    second_group = x

        if second_group is None:
            break

        n_2 = node_info[second_group]

        if not n_2:
            del node_info[second_group]
            continue

        second_node = n_2[-1]

        result.append((current_node, second_node))

        current_group = second_group

    if len(result) != (len(nodes) - 1):
        return 'NO'

    return 'YES\n{}'.format('\n'.join(['{} {}'.format(*x) for x in result]))

t = get(int)
for _ in range(t):
    l = get(int)
    nodes = get_arr(int)

    print(*solve(nodes))


for _ in range(int(input())):
    a = int(input())
    b = list(map(int,input().split()))
    if len(list(set(b)))==1:
        print("NO")
    else:
        print("YES")
        for i in range(a):
            b[i]=(b[i],i+1)
        b.sort()
        i = a-1
        while i>0 and b[i][0]!=b[0][0]:
            print(b[0][1],b[i][1])
            i-=1
        j = i+1
        while i>=1:
            print(b[i][1],b[j][1])
            i-=1


for _ in range(int(input())):
    a = int(input())
    b = list(map(int,input().split()))
    if len(list(set(b)))==1:
        print("NO")
    else:
        print("YES")
        for i in range(a):
            b[i]=(b[i],i+1)
        b.sort()
        i = a-1
        while i>0 and b[i][0]!=b[0][0]:
            print(1,b[i][1])
            i-=1
        j = i+1
        while i>1:
            print(b[i][1],b[j][1])
            i-=1


// 4/18/2020 5:40 AM
// https://codeforces.com/problemset/problem/160/A

package p160

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val nCoins = readInt()
    val coinValues = readInts().sortedDescending()
    val totalAmount = coinValues.sum()
    var subsetTotal = 0
    var subsetCoins = 0
    for (coin in coinValues) {
        subsetTotal += coin
        subsetCoins++
        if (subsetTotal > (totalAmount / 2))
            break
    }
    println(subsetCoins)
}


import java.util.*

fun main()
{
    val read = Scanner(System.`in`)
    var n = read.nextInt();

    var number = Array<Int>(n){0};

    for(i in 0..n-1)
    {
        number[i] = read.nextInt()
    }

    var temp = Array<Int>(n){1};
    var max = 1;
    for(i in 1..n-1)
    {
        if(number[i] >= number[i-1])
        {
            temp[i] = temp[i-1] + 1;
            max = Math.max(max , temp[i]);
        }
    }

    println(max);

}


import java.util.*

fun main()
{
    val read = Scanner(System.`in`)
    var n = read.nextInt();

    var number = Array<Int>(n){0};

    for(i in 0..n-1)
    {
        number[i] = read.nextInt()
    }

    var temp = Array<Int>(n){1};
    var max = Integer.MIN_VALUE;
    for(i in 1..n-1)
    {
        if(number[i] >= number[i-1])
        {
            temp[i] = temp[i-1] + 1;
            max = Math.max(max , temp[i]);
        }
    }

    println(max);

}


import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    reader.readLine().toInt()
    val ax = reader.readLine().split(' ').map { it.toInt() }
    val series = arrayListOf<ArrayList<Int>>()
    val iterator = ax.iterator()
    var prev = iterator.next()
    var currentSeries = arrayListOf<Int>(prev)
    while (iterator.hasNext()) {
        val current = iterator.next()
        if (current >= prev) {
            currentSeries.add(current)
        } else {
            series.add(currentSeries)
            currentSeries = arrayListOf(current)
        }
        prev = current
    }
    series.add(currentSeries)
    println(series.maxBy { it.count() }!!.count())
}


fun main(args: Array<String>) {
    readLine()
    val arr = readLine()!!.split(' ').map(String::toInt).toTypedArray()
    var ans = 0
    var a = 0
    for (i in arr.indices) {
        if (i == 0) {
            a = 1
        } else {
            if (arr[i] >= arr[i-1]) {
                a++
            } else {
                a = 1
            }
        }
        // print("$a\n")
        ans = if (a <= ans) ans else a
    }
    print("$ans\n")
}


fun main(args: Array<String>) {
    readLine()
    val arr = readLine()!!.split(' ').map(String::toInt)
    var ans = 0
    var a = 0
    for (i in arr.indices) {
        if (i == 0) {
            a = 1
        } else {
            if (arr[i] >= arr[i-1]) {
                a++
            } else {
                a = 1
            }
        }
        // print("$a\n")
        ans = if (a <= ans) ans else a
    }
    print("$ans\n")
}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val arr = readLine()!!.split(' ').map(String::toInt)
    var ans = 0
    var a = 0
    for (i in 0..n-1) {
        if (i == 0) {
            a = 1
        } else {
            if (arr[i] >= arr[i-1]) {
                a++
            } else {
                a = 1
            }
        }
        // print("$a\n")
        ans = if (a <= ans) ans else a
    }
    print("$ans\n")
}


fun main(args: Array<String>) {
    readLine()
    val set = readLine()!!.split(' ').map { it.toInt() }
    var count = 1
    var max = count
    set.indices.forEach{
        if (it > 0 && set[it] >= set[it-1]){
            count++
            max = max.coerceAtLeast(count)
        } else{
            count = 1
        }
    }
    println(max)
}


private fun readLn() = readLine()!!
private fun readLines() = generateSequence(::readLine)
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main() {
    readInt()
    val array = readInts().toIntArray()

    var max = 1
    var currMax = 1
    for (i in 1 until array.size) {
        if (array[i] >= array[i - 1]) {
            currMax++
            if(currMax > max){
                max = currMax
            }
        }else{
            currMax = 1
        }
    }
    println(max)
}


import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var longest = 0
    var currentLength = 0
    var prev = -1
    val scanner = Scanner(System.`in`)

    for (i in 0 until n) {
        val it = scanner.nextInt()
        if (it >= prev) {
            currentLength++
        }
        else {
            longest = maxOf(longest, currentLength)
            currentLength = 1
        }

        prev = it
    }

    println(maxOf(longest, currentLength))
}


fun main(args: Array<String>) {
    readLine()!!.toInt()
    var longest = 0
    var currentLength = 0
    var prev = -1

    fun reset() {
        longest = maxOf(longest, currentLength)
        currentLength = 1
        prev = -1
    }

    readLine()!!.split(' ').map { it.toInt() }.forEach { it ->
        if (it >= prev) {
            currentLength++
            prev = it
        }
        else {
            reset()
        }
    }

    reset()
    println(longest)
}


import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    var longest = 0
    var currentLength = 0
    var prev = -1

    for (i in 0 until n) {
        val it = scanner.nextInt()
        if (it >= prev) {
            currentLength++
        }
        else {
            longest = maxOf(longest, currentLength)
            currentLength = 1
        }

        prev = it
    }

    println(maxOf(longest, currentLength))
}


fun main(args: Array<String>) {
    readLine()!!.toInt()
    var longest = 0
    var currentLength = 0
    var prev = -1

    readLine()!!.split(' ').map { it.toInt() }.forEach { it ->
        if (it >= prev) {
            currentLength++
        }
        else {
            longest = maxOf(longest, currentLength)
            currentLength = 1
        }

        prev = it
    }

    println(maxOf(longest, currentLength))
}


import kotlin.math.max

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
private fun readIntsArr() = ArrayList(readInts()) // ArrayList of ints

private val MX = 200005
private val MOD = 1000000007
private val SZ = 1 shl 18
private val INF = (1e18).toLong()

private fun add(a: Int, b: Int) = (a + b) % MOD // from tourist :o
private fun sub(a: Int, b: Int) = (a - b + MOD) % MOD
private fun mul(a: Int, b: Int) = ((a.toLong() * b) % MOD).toInt()

private fun solve(){
    readInt()
    val a = readInts()
    var longest = 0
    var length = 1
    var last = a[0]
    for(i in 1 until a.size){
        if(a[i] < last){
            longest = max(longest, length)
            length = 0
        }
        last = a[i]
        length++
    }
    println("${max(longest, length)}")
}

fun main(){
    val t = 1  // # of test cases
    for (i in 1..t) {
        solve()
    }
}


import kotlin.math.max

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
private fun readIntsArr() = ArrayList(readInts()) // ArrayList of ints

private val MX = 200005
private val MOD = 1000000007
private val SZ = 1 shl 18
private val INF = (1e18).toLong()

private fun add(a: Int, b: Int) = (a + b) % MOD // from tourist :o
private fun sub(a: Int, b: Int) = (a - b + MOD) % MOD
private fun mul(a: Int, b: Int) = ((a.toLong() * b) % MOD).toInt()

private fun solve(){
    readInt()
    val a = readInts()
    var longest = 0
    var length = 1
    var last = a[0]
    for(i in 1 until a.size){
        length++
        if(a[i] < last){
            longest = max(longest, length)
            length = 0
        }
        last = a[i]
    }
    println("${max(longest, length)}")
}

fun main(){
    val t = 1  // # of test cases
    for (i in 1..t) {
        solve()
    }
}


import kotlin.math.max

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val n = readInt()
    val nums = readInts()
    var longest = 1
    var res = 1;
    for (i in 1 until nums.size) {
        if (nums[i] >= nums[i - 1]) {
            longest += 1
        } else {
            longest = 1;
        }
        res = max(res, longest)
    }
    println(res)
}


import kotlin.math.max

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val n = readInt()
    val nums = readInts()
    var longest = 1
    var res = 0;
    for (i in 1 until nums.size) {
        if (nums[i] > nums[i - 1]) {
            longest += 1
        } else {
            longest = 1;
        }
        res = max(res, longest)
    }
    println(res)
}


import kotlin.math.max

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val n = readInt()
    val nums = readInts()
    var longest = 1
    var res = 0;
    for (i in 1 until nums.size) {
        if (nums[i] >= nums[i - 1]) {
            longest += 1
        } else {
            longest = 1;
        }
        res = max(res, longest)
    }
    println(res)
}


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = CodeForces.FastReader()
    var n = fs.nextInt()
    var a = fs.readIntArray(n)
    var length =1
    var best = 1
    for (i in 0 until a.size-1) {
        if (a[i+1] >= a[i]) {
            length++
        }
        else{
            length=1
        }
        best = max(best,length)
    }
    println(best)
}

class CodeForces {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = CodeForces.FastReader()
    var n = fs.nextInt()
    var a = fs.readIntArray(n)
    var length =1
    var best = 0
    for (i in 0 until a.size-1) {
        if (a[i+1] >= a[i]) {
            length++
        }
        else{
            length=1
        }
        best = max(best,length)
    }
    println(best)
}

class CodeForces {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


fun main(args: Array<String>) {
	val n: Int = readLine()!!.toInt()
	val array = IntArray(n)
	val stringA = readLine()!!.split(" ")
	for(i in 0..n-1){
		array.set(i, stringA.get(i).toInt())
	}
	countNonDecDays(n, array)
}

fun countNonDecDays(n: Int, a: IntArray){
	var nonDecDays = 1
	var maxNonDecDays = 0
	for(i in 0..n-1){
		if(i == 0){
			maxNonDecDays = nonDecDays
			continue
		}

		if(a.get(i) >= a.get(i-1)){
			nonDecDays += 1
		}else{
			nonDecDays = 1
		}
		maxNonDecDays = Integer.max(maxNonDecDays, nonDecDays)
	}
	println(maxNonDecDays)
}


fun main(){
    var n = readLine()!!.toInt()
    var n1 = readLine()!!.split(' ').map { it.toInt() }
    var a1 = arrayListOf<Int>()
    var d = -1
    var e = 0
    while(e < n1.size - 1){
        if(n1[e + 1] < n1[e]){
            if(a1.size > d){
                d = a1.size
            }
            a1 = arrayListOf<Int>()
        }
        else{
            a1.add(n1[e])
        }
        e += 1
    }
    if(a1.size > d){
        d= a1.size
    }
    println(d + 1)
}


import kotlin.math.max

/* template start */
// input
private fun readString() = readLine()!!
private fun readStrings() = readString().split(" ")
private fun readInt() = readString().toInt()
private fun readDigits() = readString().map { it - '0' }
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }

// output
private fun <T> T.print(map: (T) -> String = { it.toString() }) = println(map(this))
private fun <T> Iterable<T>.print(sep: String? = null, map: ((T) -> String)? = null) = asSequence().print(sep, map)
private fun <T> Array<T>.print(sep: String? = null, map: ((T) -> String)? = null) = asSequence().print(sep, map)
private fun IntArray.print(sep: String? = null, map: ((Int) -> String)? = null) = asSequence().print(sep, map)
private fun <T> Sequence<T>.print(sep: String? = null, map: ((T) -> String)? = null) =
    println(joinToString(sep ?: "", transform = map ?: { it.toString() }))

// others
private val Int.isEven: Boolean get() = this % 2 == 0
private val Int.isOdd: Boolean get() = !this.isEven
private fun queries(block: (Int) -> Unit) = repeat(readInt(), block)

/* template end */

fun main() {
    readInt()
    val nums = readInts()
    var cnt = 1
    var best = 1
    for (i in 1 until nums.size) {
        if (nums[i - 1] <= nums[i]) cnt++
        else cnt = 1
        best = max(best, cnt)
    }
    println(best)
}


import java.io.InputStream

const val CODE_0 = '0'.toByte()
const val CODE_1 = '9'.toByte()

class Main {
    companion object {
        @JvmStatic
        fun main(args: Array<String>) = with(FastScanner(System.`in`)) {
            val n = nextInt()
            var p = 0
            var l = 0
            var m = 0
            for (i in 1..n) {
                val x = nextInt()
                if (x < p) {
                    l = 1
                } else {
                    ++l
                    if (l > m) m = l
                }
                p = x
            }
            println(m)
        }
    }

    // -----------------------------------------------------------------------------------------------------------------

    private class FastScanner(private val iss: InputStream = System.`in`) {
        fun nextInt(): Int { // todo negative
            var v = 0
            var begin = false
            while (true) {
                val c = iss.read()
                if (c in CODE_0..CODE_1) {
                    begin = true
                    v *= 10
                    v += c - CODE_0
                } else if (begin) {
                    return v
                }
            }
        }
    }
}

fun main(args: Array<String>) = Main.main(args)


#include<stdio.h>
int main()
{
    long int n;
    scanf("%ld", &n);
    long long int ara[n];
    long long int i;
    for(i=0; i<n; i++)
        scanf("%lld", &ara[i]);
    int cnt=1, result=1;
    for(i=0; i<n-1; i++)
    {
        if(ara[i]<=ara[i+1])
            cnt++;
        else
        {
            if(cnt>result)
                result=cnt;
            cnt=1;
        }
    }
    if(cnt>result)
        printf("%d\n", cnt);
    else
        printf("%d\n", result);
    return 0;
}


#include<stdio.h>

int main()
{
    long int n;
    scanf("%ld",&n);
    long int i,ara[n];
    for(i=0; i<n; i++)
        scanf("%ld",&ara[i]);
    int m=0,hold=0;
    int maximum=0;
    for(i=0; i<n; i++)
    {
        if(ara[i]==ara[i+1] || ara[i-1]<=ara[i])
        {
            m++;
            hold=m;
        }
        else
        {
            if(maximum<hold)
                maximum=hold;
            m=1;
        }
    }
    if(maximum<hold)
        maximum=hold;
    printf("%d\n",maximum);
    return 0;

}


#include<stdio.h>

int main()
{
    long int n;
    scanf("%ld",&n);
    long int i,ara[n];
    for(i=0; i<n; i++)
        scanf("%ld",&ara[i]);
    int m=0,hold=0;
    int maximum=1;
    for(i=0; i<n; i++)
    {
        if(ara[i]==ara[i+1] || ara[i-1]<=ara[i])
        {
            m++;
            hold=m;
        }
        else
        {
            if(maximum<hold)
                maximum=hold;
            m=1;
        }
    }
    if(maximum<hold)
        maximum=hold;
    printf("%d\n",maximum);
    return 0;

}


#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int i,ara[n];
    for(i=0; i<n; i++)
        scanf("%d",&ara[i]);
    int m=0,hold=0;
    int maximum=0;
    for(i=0; i<n; i++)
    {
        if(ara[i]==ara[i+1] || ara[i-1]<=ara[i])
        {
            m++;
            hold=m;
        }
        else
        {
            if(maximum<hold)
                maximum=hold;
            m=1;
        }
    }
    if(maximum<hold)
        maximum=hold;
    printf("%d\n",maximum);
    return 0;

}


#include<stdio.h>

int main()
{
    long int n;
    scanf("%ld",&n);
    long int i,ara[n];
    for(i=0; i<n; i++)
        scanf("%ld",&ara[i]);
    long int cnt=0,temp=0;
    long int maximum=1;
    for(i=0; i<n; i++)
    {
        if(ara[i]==ara[i+1] || ara[i-1]<=ara[i])
        {
            cnt++;
            temp=cnt;
        }
        else
        {
            if(maximum<temp)
                maximum=temp;
            cnt=1;
        }
    }
    if(maximum<temp)
        maximum=temp;
    printf("%ld\n",maximum);
    return 0;

}


#include <stdio.h>
#define MAX 100000
int main()
{
    int i, cont = 1, v[MAX], max = 0, n, mp = 0;
    scanf("%d", &n);
    for (i = 0; i<n; i++){
        scanf("%d", &v[i]);
        if(i > 0){
            if(v[i] >= v[i-1])
                cont += 1;
            else{
                if(cont > max)
                    max = cont;
                cont = 1;
                mp = 1;
                    }
        }
    }
    if(mp == 0)
        max = cont;
    printf("%d\n", max);
    return 0;

}


#include <stdio.h>
#define MAX 100000
int main()
{
    int i, cont = 0, v[MAX], max = 0, n, mp = 0;
    scanf("%d", &n);
    for (i = 0; i<n; i++){
        scanf("%d", &v[i]);
        if(i > 0){
            if(v[i] >= v[i-1])
                cont += 1;
            else{
                if(cont >= max)
                    max = cont+1;
                cont = 0;
                mp = 1;
                    }
        }
    }
    if(mp == 0)
        max = cont+1;
    printf("%d\n", max);
    return 0;

}


#include<stdio.h>
int main()
{
    int n,i,l=0,k=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(a[i+1]>=a[i])
            l++;
        else
        {
            if(l>k)
            {
                k=l;
                l=0;
            }
        }
    }
    if(k>l)
        printf("%d",k+1);
    else
        printf("%d",l+1);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,l=0,k=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(j=0;j<n-1;j++)
    {
        if(a[j+1]>=a[j])
            l++;
        else
        {
            if(l>k)
            {
                k=l;
                l=0;
            }
        }
    }
    if(k>l)
        printf("%d",k+1);
    else
        printf("%d",l+1);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,c=0,k=0;
    scanf("%d",&n);
    int a[n];
    int b[n-1];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(j=0;j<n-1;j++)
    {
        if(a[j+1]>=a[j])
            c++;
        else
        {
            if(c>=k)
                k=c;
                c=0;
        }
    }
    if(k>c)
        printf("%d",k+1);
    else
        printf("%d",c+1);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,l=0,k=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
    {
        if(a[i+1]>=a[i])
            l++;
        else
        {
            if(l>k)
            {
                k=l;
                l=0;
            }
        }
    }
    if(k>l)
        printf("%d",k+1);
    else
        printf("%d",l+1);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,l=0,k=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
    {
        if(a[i+1]>=a[i])
            l++;
        else
        {
            if(l>k)
            {
                k=l;
                l=0;
            }
        }
    }
    if(k>l)
        printf("%d",k+1);
    else
        printf("%d",l+1);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,c=0,k=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(j=0;j<n-1;j++)
    {
        if(a[j+1]>=a[j])
            c++;
        else
        {
            if(c>=k)
            {
                k=c;
                c=0;
            }
        }
    }
    if(k>c)
        printf("%d",k+1);
    else
        printf("%d",c+1);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,l=0,k=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++)
    {
        if(a[i+1]>=a[i])
            l++;
        else
        {
            if(l>k)
            {
                k=l
                l=0;
            }
        }
    }
    if(k>l)
        printf("%d",k+1);
    else
        printf("%d",l+1);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,c=0,k=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(j=0;j<n-1;j++)
    {
        if(a[j+1]>=a[j])
            c++;
        else
        {
            if(c>=k)
            {
                k=c;
                c=0;
            }
        }
    }
    if(k>c)
        printf("%d",k+1);
    else
        printf("%d",c+1);
    return 0;
}


#include<stdio.h>

int main()
{
    long long int n, i, temp, count=1, max=0;
    scanf("%I64d", &n);
    long long int arr[n];
    for(i=0; i<n; i++)
        scanf("%I64d", &arr[i]);
    if(n==1)
        printf("1");
    else
    {
        for(i=0; i<n-1; i++)
        {
            if(arr[i]<=arr[i+1])
            {
                count++;
            }
            temp=count;
            if(temp>max)
            {
                max=temp;
            }
            if(arr[i]>arr[i+1])
                count=1;
        }
        printf("%I64d", max);
    }

    return 0;
}


#include<stdio.h>
int main()
{
    int n,c=-1000,l=0,x,max=-1000;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&x);
        if(x>=c)
            l++;
        else
            l=1;
        c=x;
        if(l>max)
            max=l;
    }
    printf("%d\n",max);
    return 0;
}


#include "stdio.h"
#define n 100000

int main(int argc, char* argv[])
{
    long a[n];
    long m;
    long j,i;

    scanf("%d",&m);
    if(m<1||m>100000)return 0;

    for(j=0;j<m;j++){
    scanf("%d",&a[j]);
    }

    long temp=1;
    long max=0;

    for(i=0;i<m-1;i++){
        if(a[i]<1||a[i]>1000000000)return 0;

        if(a[i]<=a[i+1]){

            temp++;

            if(max<temp)
                max=temp;
            }

        else {
            temp=1;
        }
    }

    printf("%ld\n",max);
    return 0;
}


#include "stdio.h"
#define n 100000

int main(int argc, char* argv[])
{
	int a[n],m;
	int j,i;

	scanf("%d",&m);

	for(j=0;j<m;j++){
	  scanf("%d",&a[j]);
	}

	int temp=1;
	int max=0;

	for(i=0;i<m-1;i++){
		if(a[i]<=a[i+1]){

			temp++;

			if(max<temp)
				max=temp;
		}

		else {
			temp=1;
		}
	}
	printf("%d\n",max);
	return 0;
}


#include<stdio.h>
#include <string.h>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int a[100006];
    int n,i,l=1,m=1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<n;i++)
    {
        if(a[i]>=a[i-1])
        {
            l++;
        }
        else
        {
            l=1;
        }
        if(l>m)
        {
            m=l;
        }
    }
    printf("%d\n",m);
    return 0;
}


#include "stdio.h"
#define n 100000

int main(int argc, char* argv[])
{
    long a[n];
    long m;
    long j,i;

    scanf("%d",&m);

    for(j=0;j<m;j++){
    scanf("%d",&a[j]);
    }

    long temp=1;
    long max=0;

    for(i=0;i<m-1;i++){
        if(a[i]<=a[i+1]){

            temp++;

            if(max<temp)
                max=temp;
            }

        else {
            temp=1;
        }
    }

    printf("%ld\n",max);
    return 0;
}


#include "stdio.h"
#define n 100000

int main(int argc, char* argv[])
{
    int a[n],m;
    int j,i;

    scanf("%d",&m);

    for(j=0;j<m;j++){
      scanf("%d",&a[j]);
    }

    int temp=1;
    int max=0;

    for(i=0;i<m-1;i++){
        if(a[i]<=a[i+1]){

            temp++;

            if(max<temp)
                max=temp;
        }

        else {
            temp=1;
        }
    }
    printf("%d",max);
    return 0;
}


#include "stdio.h"

int main(int argc, char* argv[])
{
    long a[100006];
    long m;
    long i;

    scanf("%ld",&m);

    for(i=0;i<m;i++){
    scanf("%ld",&a[i]);
    }

    long temp=1;
    long max=1;

    for(i=1;i<m;i++){

        if(a[i-1]<=a[i]){

            temp++;

            }

        else {
            temp=1;
        }
        if(max<temp)
            max=temp;
    }

    printf("%ld\n",max);
    return 0;
}


#include "stdio.h"
#define n 100000

int main(int argc, char* argv[])
{
	long a[n];
	int m;
	int j,i;

	scanf("%d",&m);

	for(j=0;j<m;j++){
	  scanf("%d",&a[j]);
	}

	int temp=1;
	int max=0;

	for(i=0;i<m-1;i++){
		if(a[i]<=a[i+1]){

			temp++;

			if(max<temp)
				max=temp;
		}

		else {
			temp=1;
		}
	}
	printf("%d\n",max);
	return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{
    int j=0,a,b[15000],c[15000],i=0,count=0,count1=0,max=0;
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<a-1;i++)
    {
        if(b[count]==b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        else if(b[count]>b[i+1] )
        {
            count=0;
            count1=0;
            b[count]=b[i+1];
        }
        else if(b[count]<b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        c[j]=count1;
        j++;
    }
    max=c[0];
   for(i=0;i<j;i++)
   {
       if(max<c[i])
       {
           max=c[i];
       }
   }
   printf("%d",max+1);
return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{
    int j=0,a,b[100],c[100],i=0,count=0,count1=0,max=0;
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<a-1;i++)
    {
        if(b[count]==b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        else if(b[count]>b[i+1] )
        {
            count=0;
            count1=0;
            b[count]=b[i+1];
        }
        else if(b[count]<b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        c[j]=count1;
        j++;
    }
    max=c[0];
   for(i=0;i<j;i++)
   {
       if(max<c[i])
       {
           max=c[i];
       }
   }
   printf("%d",max+1);
return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{
    int a,b[100],i=0,count=0,count1=0,flag=0;
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<a-1;i++)
    {
        if(b[count]==b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        else if(b[count]>b[i+1] )
        {
            count=0;
            count1=0;
            b[count]=b[i+1];
            continue;
        }
        else if(b[count]<b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        //printf("%d\t",count1);
        flag=count1;
    }
   printf("%d",flag+1);
return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{
    int j=0,a,b[150000],c[150000],i=0,count=0,count1=0,max=0;
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<a-1;i++)
    {
        if(b[count]==b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        else if(b[count]>b[i+1] )
        {
            count=0;
            count1=0;
            b[count]=b[i+1];
        }
        else if(b[count]<b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        c[j]=count1;
        j++;
    }
    max=c[0];
   for(i=0;i<j;i++)
   {
       if(max<c[i])
       {
           max=c[i];
       }
   }
   printf("%d",max+1);
return 0;
}


#include<stdio.h>
#include<conio.h>

int main()
{
    int j=0,a,b[1500],c[1500],i=0,count=0,count1=0,max=0;
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<a-1;i++)
    {
        if(b[count]==b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        else if(b[count]>b[i+1] )
        {
            count=0;
            count1=0;
            b[count]=b[i+1];
        }
        else if(b[count]<b[i+1])
        {
            count1++;
            count++;
            b[count]=b[i+1];
        }
        c[j]=count1;
        j++;
    }
    max=c[0];
   for(i=0;i<j;i++)
   {
       if(max<c[i])
       {
           max=c[i];
       }
   }
   printf("%d",max+1);
return 0;
}


#include<stdio.h>
int main()
{
    int n, c=1, l, i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i+1]<=a[i+2])
            c++;
        else{
            if(c>l)
                l=c;
            c=1;
        }
    }
    if(c>l)
        l=c;
    printf("%d",l);
    return 0;
}


#include<stdio.h>
int main()
{
    int n, c=1, l=0, i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i+1]<=a[i+2])
            c++;
        else{
            if(c>l)
                l=c;
            c=1;
        }
    }
    if(c>l)
        l=c;
    printf("%d",l);
    return 0;
}


#include <stdio.h>

int main()
{
    int n,c=1,m=0,i;
    scanf("%d",&n);
    int a[n];
    scanf("%d",&a[0]);
    for(i=1;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>=a[i-1])
            c++;
        else
        {
            if(c>m)
                m=c;
            c=1;
        }
    }
    if(c>m)
        m=c;
    printf("%d",m);
    return 0;
}


#include<stdio.h>
int main()
{
   long long int f=0,n,i,m;
   scanf("%I64d",&n);
   long long int a[n];
   for(i=1;i<=n;i++)
        scanf("%I64d",&a[i]);
   for(i=1;i<n;i++)
   {
       if(a[i+1]==0)
        break;
     else  if(a[i]<=a[i+1])
        {
        f=f+1;
        m=f;
        }
        else
            f=0;
   }
      printf("%I64d",m+1);
}


#include <bits/stdc++.h>

using namespace std;
const n=123456789;
int main()
{
  int n,count=1,a[n];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
   scanf("%d",&a[i]);
  }
  for(int i=0;i<n;i++){
   if(a[i]>a[i+1])
    count+=1;
   if(a[i]==a[i+1]){
    if(a[i+1]<a[i+2])
        count+=2;
   }
  }
  printf("%d\n",count);
    return 0;
}


#include<stdio.h>
int main()
{
    int i,n,t,max=0;
    int a[10009];
    while(scanf("%d",&n)!=EOF)
    {
       for(i=0;i<n;i++)
       {
           scanf("%d",&a[i]);
       }
       if(n==1)
        printf("1\n");
       else{
        for(i=1,t=1;i<n;i++)
        {
            if(a[i]>=a[i-1])
            {
                t++;
                 if(t>max)
                {
                    max=t;
                }
            }
            else
            {
                t=1;
            }
        }
        printf("%d\n",max);
       }
    }
    return 0;
}


#include<stdio.h>
main()
{
	int n,a[100009],i,j,judge=1,max=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<n;i++)
	{
		if(a[i]>=a[i-1])judge++;
		else judge=1;
		if(judge>max)
			max=judge;
	}
	printf("%d\n",max);
	return 0;
}


#include<stdio.h>
int main()
{
    int i,n,t,max=0;
    int a[10009];
       for(i=0;i<n;i++)
       {
           scanf("%d",&a[i]);
       }
       if(n==1)
        printf("1\n");
       else{
        for(i=1,t=1;i<n;i++)
        {
            if(a[i]>=a[i-1])
            {
                t++;
                 if(t>max)
                {
                    max=t;
                }
            }
            else
            {
                t=1;
            }
        }
        printf("%d\n",max);
       }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MA=3000001;
ll a[MA],b[MA];
int main()
{
    int n,flag=0;
    cin>>n;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;++i){
        cin>>a[i];
        if(a[i]>1)flag=1;
        else a[i]=0;
    }
    if(flag==0){
        cout<<"0"<<endl;
        return 0;
    }
    ll ans=0;
    for(int i=0;i<n;++i){
        int j=i;
        while(a[i]&&j<n){
            if(i==j&&a[i]>=3){
                ans+=a[i]/3;
                a[i]%=3;
            }
            else if(i!=j&&a[j]>=2){
                ll temp=min(a[i],a[j]/2);
                ans+=temp;
                a[i]-=temp;
                a[j]-=temp*2;
            }
            else{
                j++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MA=3000001;
ll a[MA],b[MA];
int main()
{
    int n;
    cin>>n;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n;++i){
        int j=i;
        while(a[i]&&j<n){
            if(i==j&&a[i]>=3){
                ans+=a[i]/3;
                a[i]%=3;
            }
            else if(i!=j&&a[j]>=2){
                ll temp=min(a[i],a[j]/2);
                ans+=temp;
                a[i]-=temp;
                a[j]-=temp*2;
            }
            else{
                j++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MA=300005;
int main()
{
    int n;
    cin>>n;
    ll ans=0,flag=0,a;
    for(int i=0;i<n;++i){
        cin>>a;
        if(flag){
           ll temp=min(flag,a/2);
           flag-=temp;
           a-=2*temp;
           ans+=temp;
        }
        ans+=a/3;
        flag+=a%3;
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MA=3000001;
ll a[MA],b[MA];
int main()
{
    int n,flag=0;
    cin>>n;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;++i){
        cin>>a[i];
        if(a[i]>1)flag=1;
    }
    if(flag){
        cout<<"0"<<endl;
        return 0;
    }
    ll ans=0;
    for(int i=0;i<n;++i){
        int j=i;
        while(a[i]&&j<n){
            if(i==j&&a[i]>=3){
                ans+=a[i]/3;
                a[i]%=3;
            }
            else if(i!=j&&a[j]>=2){
                ll temp=min(a[i],a[j]/2);
                ans+=temp;
                a[i]-=temp;
                a[j]-=temp*2;
            }
            else{
                j++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MA=3000001;
ll a[MA],b[MA];
int main()
{
    int n,flag=0;
    cin>>n;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;++i){
        cin>>a[i];
        if(a[i]>1)flag=1;
    }
    if(flag==0){
        cout<<"0"<<endl;
        return 0;
    }
    ll ans=0;
    for(int i=0;i<n;++i){
        int j=i;
        while(a[i]&&j<n){
            if(i==j&&a[i]>=3){
                ans+=a[i]/3;
                a[i]%=3;
            }
            else if(i!=j&&a[j]>=2){
                ll temp=min(a[i],a[j]/2);
                ans+=temp;
                a[i]-=temp;
                a[j]-=temp*2;
            }
            else{
                j++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int64;

#define ALL(c) (c).begin(), (c).end()
#define SZ(c) (c).size()

const int MAXN = 1 << 19;

int N;
int a[MAXN];
int64 ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (a[i] % 3 == 0) {
      ans += a[i] / 3;
      a[i] = 0;
    }
  }

  int lo = 0;
  for (int i = N - 1; i >= 0; --i) {
    while (a[i] > 1) {
      while (lo < i && a[lo] == 0) lo++;
      if (lo >= i) break;
      int d = min(a[lo], a[i] / 2);
      a[lo] -= d;
      a[i] -= d * 2;
      ans += d;
    }
    ans += a[i] / 3;
    a[i] %= 3;
  }

  cout << ans;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int64;

#define ALL(c) (c).begin(), (c).end()
#define SZ(c) (c).size()

const int MAXN = 1 << 19;

int N;
int a[MAXN];
int64 ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }

  int lo = 0;
  for (int i = N - 1; i >= 0; --i) {
    while (a[i] > 1) {
        while (lo < i && a[lo] == 0) lo++;
        if (lo >= i) break;
        int d = min(a[lo], a[i] / 2);
        if (a[i] - d * 2 == 1) { // going to 1 is bad
          --d;
          if (d <= 0) break;
        }
        a[lo] -= d;
        a[i] -= d * 2;
        ans += d;
    }
    ans += a[i] / 3;
    a[i] %= 3;
  }

  cout << ans;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int N, a;
long long ans, s;
int main() {
  for (cin >> N; N--;) {
    cin >> a;
    s += a;
    ans = min(s/3, ans+a/2);
  }
  cout << ans;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int64;

#define ALL(c) (c).begin(), (c).end()
#define SZ(c) (c).size()

const int MAXN = 1 << 19;

int N;
int a[MAXN];
int64 ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (a[i] % 3 == 0) {
      ans += a[i] / 3;
      a[i] = 0;
    }
  }

  int lo = 0;
  for (int i = N - 1; i >= 0; --i) {
    while (a[i] > 1) {
      while (lo < i && a[lo] == 0) lo++;
      if (lo >= i) break;
      int d = min(a[lo], a[i] / 2);
      a[lo] -= d;
      a[i] -= d * 2;
      ans += d;
    }
  }

  cout << ans;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int64;

#define ALL(c) (c).begin(), (c).end()
#define SZ(c) (c).size()

const int MAXN = 1 << 19;

int N;
int a[MAXN];
int64 ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    if (a[i] % 3 != 1) {
      ans += a[i]  / 3;
      a[i] %= 3;
    }
    else if (a[i] > 1) {
      ans += (a[i] - 3) / 3;
      a[i] = 4;
    }
  }

  int lo = 0;
  for (int i = N - 1; i >= 0; --i) {
    while (a[i] > 1) {
      while (lo < i && a[lo] == 0) lo++;
      if (lo >= i) break;
      int d = min(a[lo], a[i] / 2);
      ans += d;
      a[lo] -= d;
      a[i] -= 2 * d;

    }
      ans += a[i]  / 3;
      a[i] %= 3;
  }

  cout << ans;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int64;

#define ALL(c) (c).begin(), (c).end()
#define SZ(c) (c).size()

const int MAXN = 1 << 19;

int N;
int a[MAXN];
int64 ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    ans += (a[i] / 6) * 2;
    a[i] %= 6;
  }

  int lo = 0;
  for (int i = N - 1; i >= 0; --i) {
    if (a[i] == 3) { a[i] = 0; ans++; continue ; }
    if (a[i] == 5) { a[i] = 2; ans++; }
    if (a[i] == 0 || a[i] == 1) { continue ; }
    while (a[i] > 1) {
        while (lo < i && a[lo] == 0) lo++;
        if (lo >= i) break;
        int d = min(a[lo], a[i] / 2);
        a[lo] -= d;
        a[i] -= d * 2;
        ans += d;
    }
    ans += a[i] / 3;
    a[i] %= 3;
  }

  cout << ans;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int64;

#define ALL(c) (c).begin(), (c).end()
#define SZ(c) (c).size()

const int MAXN = 1 << 19;

int N;
int a[MAXN];
int64 ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    ans += a[i] / 3;
    a[i] %= 3;
  }

  int lo = 0;
  for (int i = N - 1; i >= 0; --i) {
    if (a[i] == 2) {
      while (lo < i && a[lo] == 0) lo++;
      if (lo >= i) break;
      --a[lo];
      a[i] -= 2;
      ans++;
    }
  }

  cout << ans;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q[2];
int n,a[300005];
long long ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		ans+=a[i]/3;
		a[i]%=3;
		if(a[i]){
			Q[a[i]&1].push(i);
		}
	}
	while(!Q[0].empty()){
		if(Q[1].empty()){
			ans+=Q[0].size()*2/3;
			break;
		}
		while(!Q[1].empty()&&Q[1].top()>Q[0].top())Q[1].pop();
		if(!Q[1].empty()){
			ans++;
			Q[1].pop();Q[0].pop();
		}
	}
	printf("%I64d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q;
int n,a[300005],z,i;
long long ans;
bool f;
void R(){
	a[i]-=2;
	if(!Q.empty()){
		while(!Q.empty()&&Q.top()>i)Q.pop();
		if(!Q.empty()){
			Q.pop();ans++;
			return;
		}
	}
	while(a[z]<=0){
		z++;
		if(z>i){
			f=1;return;
		}
	}
	a[z]--;ans++;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]==1)Q.push(i);
	}
	for(i=n;i;i--){
		if(z>i)break;
		if(a[i]%3==0)ans+=a[i]/3;
		else if(a[i]%3==1){
			if(a[i]==1)continue;
			ans+=(a[i]-4)/3;a[i]=4;
			R();if(f)break;
			R();if(f)break;
		}
		else {
			ans+=(a[i]-2)/3;a[i]=2;
			R();if(f)break;
		}
	}
	printf("%I64d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q;
int n,a[300005],z,i;
long long ans,k;
bool f;
void R(){
	if(z<Q.top())return;
	while(!a[z]){
		z--;
		if(z<Q.top())return;
	}
	a[z]-=2;ans++;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]%2==1){
			Q.push(i);
			a[i]--;
		}
	}
	z=n;
	while(!Q.empty()){
		R();Q.pop();
	}
	for(int i=1;i<=n;++i)k+=a[i];
	ans+=k/3;
	printf("%I64d",ans);
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q[2];
int n,a[300005],z;
long long ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	for(int i=n;i;i--){
		if(z>i)break;
//		printf("%d %d %lld\n",i,a[i],ans);
		if(a[i]%3==0)ans+=a[i]/3;
		else if(a[i]%3==1){
			if(a[i]!=1){
				ans+=(a[i]-4)/3;
				while(!a[z]){
					z++;
					if(z>i)break;
				}
				a[z]--;ans++;
				while(!a[z]){
					z++;
					if(z>i)break;
				}
				a[z]--;ans++;
			}
		}
		else {
			ans+=(a[i]-2)/3;
			while(!a[z]){
				z++;
				if(z>i)break;
			}
			a[z]--;ans++;
		}
	}
	printf("%I64d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q;
int n,a[300005],z,i;
long long ans;
bool f;
void R(){
	a[i]-=2;
	if(!Q.empty()){
		while(!Q.empty()&&Q.top()>i)Q.pop();
		if(!Q.empty()){
			Q.pop();ans++;
			return;
		}
	}
	while(!a[z]){
		z++;
		if(z>i){
			f=1;return;
		}
	}
	a[z]--;ans++;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]==1)Q.push(i);
	}
	for(i=n;i;i--){
		if(z>i)break;
		if(a[i]%3==0)ans+=a[i]/3;
		else if(a[i]%3==1){
			if(a[i]==1)continue;
			ans+=(a[i]-4)/3;a[i]=4;
			R();if(f)break;
			R();if(f)break;
		}
		else {
			ans+=(a[i]-2)/3;a[i]=2;
			R();if(f)break;
		}
	}
	printf("%I64d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q;
int n,a[300005],z,i;
long long ans;
bool f;
void R(){
	if(!Q.empty()){
		while(!Q.empty()&&Q.top()>i)Q.pop();
		if(!Q.empty()){
			Q.pop();ans++;a[i]-=2;
			return;
		}
	}
	while(!a[z]){
		z++;
		if(z>i){
			f=1;return;
		}
	}
	a[z]--;ans++;a[i]-=2;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]==1)Q.push(i);
	}
	for(i=n;i;i--){
		if(z>i)break;
		if(a[i]%3==0)ans+=a[i]/3;
		else if(a[i]%3==1){
			if(a[i]==1)continue;
			ans+=(a[i]-4)/3;a[i]=4;
			R();if(f)break;
			R();if(f)break;
		}
		else {
			ans+=(a[i]-2)/3;a[i]=2;
			R();if(f)break;
		}
	}
	printf("%I64d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q[2];
int n,a[300005],z;
long long ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	for(int i=n;i;i--){
		if(z>=i)break;
		if(a[i]%3==0)ans+=a[i]/3;
		else if(a[i]%3==1){
			if(a[i]!=1){
				ans+=(a[i]-4)/3;
				if(a[z])a[z]--;
				else {
					z++;
					if(z>=i)break;
				}
				ans++;
				if(a[z])a[z]--;
				else {
					z++;
					if(z>=i)break;
				}
				ans++;
			}
		}
		else {
			ans+=(a[i]-2)/3;
			if(a[z])a[z]--;
			else {
				z++;
				if(z>=i)break;
			}
			ans++;
		}
	}
	printf("%I64d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q;
int n,a[300005],z,i;
long long ans;
bool f;
void R(){
	if(!Q.empty()){
		while(!Q.empty()&&Q.top()>i)Q.pop();
		if(!Q.empty()){
			Q.pop();ans++;
			return;
		}
	}
	while(!a[z]){
		z++;
		if(z>i){
			f=1;return;
		}
	}
	a[z]--;ans++;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]==1)Q.push(i);
	}
	for(i=n;i;i--){
		if(z>i)break;
		if(a[i]%3==0)ans+=a[i]/3;
		else if(a[i]%3==1){
			if(a[i]==1)continue;
			ans+=(a[i]-4)/3;a[i]=0;
			R();if(f)break;
			R();if(f)break;
		}
		else {
			ans+=(a[i]-2)/3;a[i]=0;
			R();if(f)break;
		}
	}
	printf("%I64d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
stack<int>Q;
int n,a[300005],z,i;
long long ans;
bool f;
void R(){
	a[i]-=2;
	if(!Q.empty()){
		while(!Q.empty()&&Q.top()>i)Q.pop();
		if(!Q.empty()){
			a[Q.top()]=0;
			Q.pop();ans++;
			return;
		}
	}
	while(a[z]<=0){
		z++;
		if(z>i){
			f=1;return;
		}
	}
	a[z]--;ans++;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]==1)Q.push(i);
	}
	for(i=n;i;i--){
		if(z>i)break;
		if(a[i]%3==0)ans+=a[i]/3;
		else if(a[i]%3==1){
			if(a[i]==1)continue;
			ans+=(a[i]-4)/3;a[i]=4;
			R();if(f)break;
			R();if(f)break;
		}
		else {
			ans+=(a[i]-2)/3;a[i]=2;
			R();if(f)break;
		}
	}
	printf("%I64d\n",ans);
}


/*
*/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
inline long int read(){
    char C=getchar();
    long int N=0,F=1;
    while(('0' > C || C > '9') && (C != '-')) C=getchar();
    if(C == '-') F=-1 , C=getchar();
    while('0' <= C && C <= '9') N=(N << 1)+(N << 3)+(C - 48) , C=getchar();
    return F*N;
}
int DT[300005];
int main() {
    ios::sync_with_stdio(false);
    int N,sm;
    long long int ans;
    cin>>N;
    for(int i=1;i<=N;i++)cin>>DT[i];
    sm=ans=0;
    for(int i=1;i<=N;i++){
        int temp=min(sm,DT[i]/2);
        ans+=temp;
        DT[i]-=temp*2;
        sm-=temp;
        ans+=DT[i]/3;
        sm+=DT[i]%3;
    }
    cout<<ans;
    return 0;
}


/*
*/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
inline long int read(){
    char C=getchar();
    long int N=0,F=1;
    while(('0' > C || C > '9') && (C != '-')) C=getchar();
    if(C == '-') F=-1 , C=getchar();
    while('0' <= C && C <= '9') N=(N << 1)+(N << 3)+(C - 48) , C=getchar();
    return F*N;
}
int DT[300005];
int main() {
    ios::sync_with_stdio(false);
    int N,sm;
    long long int ans;
    cin>>N;
    for(int i=1;i<=300000;i++)cin>>DT[i];
    sm=ans=0;
    for(int i=1;i<=N;i++){
        int temp=min(sm,DT[i]/2);
        ans+=temp;
        DT[i]-=temp*2;
        ans+=DT[i]/3;
        sm+=DT[i]%3;
    }
    cout<<ans;
    return 0;
}


/*
*/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
inline long int read(){
    char C=getchar();
    long int N=0,F=1;
    while(('0' > C || C > '9') && (C != '-')) C=getchar();
    if(C == '-') F=-1 , C=getchar();
    while('0' <= C && C <= '9') N=(N << 1)+(N << 3)+(C - 48) , C=getchar();
    return F*N;
}
int DT[300005];
int main() {
    ios::sync_with_stdio(false);
    int N,sm,eq;
    long long int ans;
    cin>>N;
    for(int i=1;i<=N;i++)cin>>DT[i];
    sm=eq=ans=0;
    for(int i=1;i<=N;i++){
        ans+=DT[i]/3;
        if(DT[i]%3==2&&sm){
            ans++;
            sm--;
        }
        else sm+=DT[i]%3;
    }
    cout<<ans;
    return 0;
}


/*
*/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
inline long int read(){
    char C=getchar();
    long int N=0,F=1;
    while(('0' > C || C > '9') && (C != '-')) C=getchar();
    if(C == '-') F=-1 , C=getchar();
    while('0' <= C && C <= '9') N=(N << 1)+(N << 3)+(C - 48) , C=getchar();
    return F*N;
}
int DT[300005];
int main() {
    ios::sync_with_stdio(false);
    int N,sm,eq,ans;
    cin>>N;
    for(int i=1;i<=N;i++)cin>>DT[i];
    sm=eq=ans=0;
    for(int i=1;i<=N;i++){
        ans+=DT[i]/3;
        if(DT[i]%3==2&&sm){
            ans++;
            sm--;
        }
        else sm+=DT[i]%3;
    }
    cout<<ans;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

typedef long long LL ;
const int N=3e5+100 ;

int a[N] ;
int n ;

int main ()
{
	int i , j ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
	int res=0 ;
	for ( i=j=1 ; i<=n ; i++ )
	{
		while ( !a[j] && j<i ) j++ ;
		if ( a[i]<2 ) continue ;
		if ( i==j )
		{
			if ( a[i]>=3 ) a[i]-=3,res++;
			else continue ;
		}
		else a[i]-=2,a[j]--,res++;
	}
	printf("%d\n",res);
	return 0 ;
}


#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

typedef long long LL ;
const int N=3e5+100 ;

LL a[N] ;
int n ;

int main ()
{
	int i , j ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ ) scanf("%I64d",a+i);
	LL res=0 , sum=0 ;
	for ( i=1 ; i<=n ; i++ )
	{
		if ( !sum ) res+=a[i]/3,sum+=a[i]%3;
		else
		{
			if ( a[i]/2<sum ) res+=a[i]/2,sum-=a[i]/2,sum+=a[i]%2;
			else res+=sum,a[i]-=sum*2,sum=0,res+=a[i]/3,sum=a[i]%3;
		}
	}
	printf("%I64d\n",res);
	return 0 ;
}


#include <algorithm>
#include <cstdio>

using namespace std ;

typedef long long LL ;

int n ;

int main ()
{
	int i ;
	LL x , s=0 , res=0 , t ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ )
	{
		scanf("%lld",&x),t=min(x>>1,s),
		s-=t,res+=t,x-=(t<<1),
		res+=x/3,x%=3,
		s+=x;
	}
	printf("%lld\n",res);
	return 0 ;
}


#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

typedef long long LL ;
const int N=3e5+100 ;

LL a[N] ;
int n ;

int main ()
{
	int i , j ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ ) scanf("%I64d",a+i);
	LL res=0 ;
	for ( i=1,j=0 ; i<=n ; i++ )
	{
		while ( !a[j] && j<i ) j++;
		if ( i==j ) res+=a[i]/3,a[i]%=3;
		else
		{
			if ( a[i]<a[j]*2 ) res+=a[i]/2ll,a[j]-=a[i]/2,a[i]%=2;
			else res+=a[j],a[i]-=2*a[j],a[j]=0;
		}
	}
	printf("%I64d\n",res);
	return 0 ;
}


#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

typedef long long LL ;
const int N=3e5+100 ;

int a[N] ;
int n ;

int main ()
{
	int i , j ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
	int res=0 ;
	res+=a[1]/3,a[1]%=3;
	for ( i=2,j=1 ; i<=n ; i++ )
	{
		while ( !a[j] && j<i ) j++;
		if ( i==j ) res+=a[i]/3,a[i]%=3;
		else
		{
			if ( a[i]/2<a[j] ) res+=a[i]/2,a[j]-=a[i]/2,a[i]%=2;
			else res+=a[j],a[i]-=2*a[j],a[j]=0;
		}
	}
	printf("%d\n",res);
	return 0 ;
}


#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define N 300010
#define M 400
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
const double PI = acos(-1);
#define NOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fi first
#define se second
#define L o<<1
#define R o<<1|1
#define tl tree[o].l
#define tr tree[o].r
#define tlw tree[o].lw
#define trw tree[o].rw
#define tmw tree[o].mw
#define rep(i, lll, nnn) for(int i = (lll); i <= (nnn); i++)

int n;
int a[N];

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("data.txt", "r", stdin);
    #endif
    NOS;

    while(cin >> n) {
        rep(i, 1, n) cin >> a[i];

        int i = 1;
        int ans = 0;

        for(int j = 1; j <= n; ) {
            if(i == j) {
                ans += a[i] / 3;
                a[i] %= 3;
                j++;
            }
            if(j == n + 1) break;
            if(a[j] >= 2 && a[i] > 0) {
                int t = min(a[j] / 2, a[i]);

                a[j] -= 2 * t;
                a[i] -= t;
                ans += t;
            }
            if(a[j] < 2) {
                j++;
            }
            else i++;
//cout << i << ' ' << j << ' ' << a[i] << ' ' << a[j] << ' ' << ans << endl;
        }

        cout << ans << endl;
    }

    return 0;
}


#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define N 300010
#define M 400
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
const double PI = acos(-1);
#define NOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fi first
#define se second
#define L o<<1
#define R o<<1|1
#define tl tree[o].l
#define tr tree[o].r
#define tlw tree[o].lw
#define trw tree[o].rw
#define tmw tree[o].mw
#define rep(i, lll, nnn) for(int i = (lll); i <= (nnn); i++)

int n;
int a[N];

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("data.txt", "r", stdin);
    #endif
    NOS;

    while(cin >> n) {
        rep(i, 1, n) cin >> a[i];

        int i = 1;
        int ans = 0;

        for(int j = 1; j <= n; ) {
            if(i == j) {
                while(a[i] >= 3) {
                    a[i] -= 3;
                    ans++;
                }
                j++;
            }
            while(a[j] >= 2 && a[i] > 0) {
                a[j] -= 2;
                a[i]--;
                ans++;
            }
            if(a[j] < 2) {
                j++;
            }
            else i++;
        }

        cout << ans << endl;
    }

    return 0;
}


#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define N 400
#define M 400
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
const double PI = acos(-1);
#define NOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fi first
#define se second
#define L o<<1
#define R o<<1|1
#define tl tree[o].l
#define tr tree[o].r
#define tlw tree[o].lw
#define trw tree[o].rw
#define tmw tree[o].mw
#define rep(i, lll, nnn) for(int i = (lll); i <= (nnn); i++)

int n;
int a[N];

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("data.txt", "r", stdin);
    #endif
    NOS;

    while(cin >> n) {
        rep(i, 1, n) cin >> a[i];

        int i = 1;
        int ans = 0;

        for(int j = 1; j <= n; ) {
            if(i == j) {
                while(a[i] >= 3) {
                    a[i] -= 3;
                    ans++;
                }
                j++;
            }
            while(a[j] >= 2 && a[i] > 0) {
                a[j] -= 2;
                a[i]--;
                ans++;
            }
            if(a[j] < 2) {
                j++;
            }
            else i++;
        }

        cout << ans << endl;
    }

    return 0;
}


#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define N 300010
#define M 400
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
const double PI = acos(-1);
#define NOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fi first
#define se second
#define L o<<1
#define R o<<1|1
#define tl tree[o].l
#define tr tree[o].r
#define tlw tree[o].lw
#define trw tree[o].rw
#define tmw tree[o].mw
#define rep(i, lll, nnn) for(int i = (lll); i <= (nnn); i++)

int n;
int a[N];

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("data.txt", "r", stdin);
    #endif
    NOS;

    while(cin >> n) {
        rep(i, 1, n) cin >> a[i];

        int i = 1;
        int ans = 0;

        for(int j = 1; j <= n; ) {
            if(i == j) {
                ans += a[i] / 3;
                a[i] %= 3;
                j++;
            }
            if(a[j] >= 2 && a[i] > 0) {
                int t = max(a[j] / 2, a[i]);

                a[j] -= 2 * t;
                a[i] -= t;
                ans += t;
            }
            if(a[j] < 2) {
                j++;
            }
            else i++;
        }

        cout << ans << endl;
    }

    return 0;
}


#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define N 300010
#define M 400
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
const double PI = acos(-1);
#define NOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fi first
#define se second
#define L o<<1
#define R o<<1|1
#define tl tree[o].l
#define tr tree[o].r
#define tlw tree[o].lw
#define trw tree[o].rw
#define tmw tree[o].mw
#define rep(i, lll, nnn) for(int i = (lll); i <= (nnn); i++)

int n;
int a[N];

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("data.txt", "r", stdin);
    #endif
    NOS;

    while(cin >> n) {
        rep(i, 1, n) cin >> a[i];

        int i = 1;
        ll ans = 0;

        for(int j = 1; j <= n; ) {
            if(i == j) {
                ans += a[i] / 3;
                a[i] %= 3;
                j++;
            }
            //if(j == n + 1) break;

            int t = min(a[j] / 2, a[i]);

            a[j] -= 2 * t;
            a[i] -= t;
            ans += t;

            while(j <= n && a[j] < 2) j++;
            while(i <= n && a[i] == 0) i++;

//cout << i << ' ' << j << ' ' << a[i] << ' ' << a[j] << ' ' << ans << endl;
        }
//rep(i, 1, n) cout << a[i] << ' ';cout << endl;

        cout << ans << endl;
    }

    return 0;
}


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = 0;
	f(i , 1, n - 1) {
		dp[i] = a[i] / 2  + dp[i-1];
		dp[i] = max(dp[i] , sum[i]/3);
		ans = max(ans, dp[i]);
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
		dp[i] = max(dp[i] , dp[i-1]);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = 0;
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = a[i] / 2  + dp[i-1];
		dp[i] = max(dp[i] , min(a[i] / 2 , sum[i-1]));
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = dp[0];
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] = max(dp[i] , min(a[i] / 2 , sum[i - 1] - 3*X) + X);
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = 0;
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] = max(dp[i] , min(a[i] / 2 , sum[i-1]));
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
		dp[i] = max(dp[i],dp[i-1]);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = 0;
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] = max(dp[i] , min(a[i] / 2 , sum[i]/3));
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = 0;
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] = max(dp[i] , min(a[i] / 2 , sum[i-1] - 3*X) + X);
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = 0;
	f(i , 1, n - 1) {
		dp[i] = min( a[i] / 2 , sum[i-1] - dp[i-1]*3) + dp[i-1];
		dp[i] = max(dp[i] , sum[i]/3);
		ans = max(ans, dp[i]);
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	//	cout << dp[i];
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = dp[0];
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] = max(dp[i] , min(a[i] / 2 , sum[i] - 1 - 3*X) + X);
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	f(i , 1, n - 1) {
		int tmp = 0;
		if(a[i] %2 && a[i] >= 3) tmp = 1, a[i]-=3;
		dp[i] = min(a[i] / 2 , sum[i - 1] - 3*dp[i-1] ) + dp[i-1];
		dp[i] += tmp;
		//cout << tmp << " ";
		ans = max(ans, dp[i]);
		//cout << dp[i] << endl;
	}
	cout << ans;
 }


/***************
		Jennifer Wilson
****************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector <int>
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i = a; i <= b; i++)
#define r(i,a,b) for(int i = b; i >= a ; i--)
#define fi first
#define se second
#define int ll
vector <int> dp(300000,0);
vector <int> sum(300000,0);
vector <int> a;
signed main() {
    IOS;
    int n,ans = -1ll;
    cin >> n;
    f( i ,0 , n - 1) {
    	int c;
    	cin >> c;
    	a.pb(c);
    	sum[i] = (i==0?c:sum[i-1] +c );
	}
//	memset(dp,0,sizeof(dp));
	dp[0] = a[0] / 3;
	ans = dp[0];
	int X = 0;
	f(i , 1, n - 1) {
		dp[i] = a[i] / 2  + dp[i-1];
		dp[i] = min(dp[i] , sum[i]/3);
		ans = max(ans, dp[i]);
		dp[i] = max(dp[i],dp[i-1]);
		X = min(dp[i] , X);
	//	cout << dp[i];
	}
	cout << ans;
 }


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef long long int ll;
const int N=5e5+5;
ll n,a[N],lst,ans,o,e,tmp;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        lst+=(a[i]/3);
        o+=a[i];
    }
    for(int i=n-1;i>=0;i--){
        o-=a[i];
        if(o<=0) a[i]+=o;
        o=max(0ll,o); a[i]=max(0ll,a[i]);
        tmp= min(o,a[i]/2);
        a[i]-=(tmp*2);
        o-=tmp;
        ans+=tmp;
        ans+=(a[i]/3);
    }
    cout<<max(ans,lst)<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef unsigned long long int ll;
const int N=5e5+5;
int n,a[N],lst,tmp;
ll ans;
queue <int> q;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+= (a[i]/3);
        a[i]%=3;
    }
    for(int i=n-1;i>0;i--){
        if(a[i]!=1)
            continue;
        if(a[i-1]==2){
            a[i]=a[i-1]=0;
        }
        else
            q.push(i);
    }
    if(a[0]==1) q.push(0);
    for(int i=n-1;i>=lst;i--){
        if(!a[i]) continue;
        if(a[i]==2){
            if(q.size()){
                tmp=q.front();
                q.pop();
                a[tmp]--;
                a[i]=0;
                ans++;
            }
            else{
                while(!a[lst]) lst++;
                if(lst==i) break;
                    a[lst]--;
                ans++;
                a[i]=0;
                q.push(lst);
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef unsigned long long int ll;
const int N=5e5+5;
int n,a[N],lst,tmp;
ll ans;
queue <int> q;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+= (a[i]/3);
        a[i]%=3;
    }
    for(int i=n-1;i>0;i--){
        if(a[i]!=1)
            continue;
        if(a[i-1]==2){
            a[i]=a[i-1]=0;
        }
        else
            q.push(i);
    }
    for(int i=n-1;i>=lst;i--){
        if(!a[i]) continue;
        if(a[i]==2){
            if(q.size()){
                tmp=q.front();
                q.pop();
                a[tmp]--;
                a[i]=0;
                ans++;
            }
            else{
                while(!a[lst]) lst++;
                if(lst==i) break;
                    a[lst]--;
                ans++;
                a[i]=0;
                q.push(lst);
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef unsigned long long int ll;
const int N=5e5+5;
ll n,a[N],lst,ans,o,e,tmp;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];

    for(int i=0;i<n;i++){
        tmp= min(a[i]/2,o);
        ans+=tmp;
        o-=tmp;
        a[i]-=(tmp*2);
        if(a[i]){
            if( (a[i+1]%3) ){
                tmp= min(a[i+1]/2,a[i]);
                ans+=tmp;
                a[i]-=tmp;
                a[i+1]-=(tmp*2);
            }
            ans+= (a[i]/3);
            a[i]%=3;
            o+=a[i];
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef long long int ll;
const int N=5e5+5;
ll n,a[N],lst,ans,o,e,tmp;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];

    for(int i=0;i<n;i++){
        tmp= min(o,a[i]/2);
        a[i]-=(tmp*2);
        o-=tmp;
        ans+=tmp;
        ans+=(a[i]/3);
        o+= (a[i]%3);
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef unsigned long long int ll;
const int N=5e5+5;
int n,a[N],lst,tmp;
ll ans;
queue <int> q;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+= (a[i]/3);
        a[i]%=3;
    }
    for(int i=n-1;i>0;i--){
        if(a[i]!=1)
            continue;
        if(a[i-1]==2){
            a[i]=a[i-1]=0;
            ans++;
        }
        else
            q.push(i);
    }
    if(a[0]==1) q.push(0);
    for(int i=n-1;i>=lst;i--){
        if(!a[i]) continue;
        if(a[i]==2){
            if(q.size()){
                tmp=q.front();
                q.pop();
                a[tmp]--;
                a[i]=0;
                ans++;
            }
            else{
                while(!a[lst]) lst++;
                if(lst==i) break;
                    a[lst]--;
                ans++;
                a[i]=0;
                q.push(lst);
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef unsigned long long int ll;
const int N=5e5+5;
int n,a[N],lst;
ll ans;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+= (a[i]/3);
        a[i]%=3;
    }
    for(int i=n-1;i>=lst;i--){
        if(!a[i]) continue;
        if(a[i]==2){
            while(!a[lst]) lst++;
            if(lst==i) break;
            a[lst]--;
            ans++;
            a[i]=0;
        }
        else{
            if(i&&a[i-1]==2){
                ans++;
                a[i]=a[i-1]=0;
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef unsigned long long int ll;
const int N=5e5+5;
int n,a[N],lst,tmp;
ll ans;
queue <int> q;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+= (a[i]/3);
        a[i]%=3;
        if(a[i]==1)
            q.push(i);

    }
    for(int i=n-1;i>=lst;i--){
        if(!a[i]) continue;
        if(a[i]==2){
            if(q.size()){
                tmp=q.front();
                q.pop();
                a[tmp]--;
                a[i]=0;
                ans++;
            }
            else{
                while(!a[lst]) lst++;
                if(lst==i) break;
                    a[lst]--;
                ans++;
                a[i]=0;
                q.push(lst);
            }
        }
        else{
            if(i&&a[i-1]==2){
                ans++;
                a[i]=a[i-1]=0;
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef unsigned long long int ll;
const int N=5e5+5;
ll n,a[N],lst,ans,o,e,tmp;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];

    for(int i=0;i<n;i++){
        tmp= min(a[i]/2,o);
        ans+=tmp;
        o-=tmp;
        a[i]-=(tmp*2);
        if(a[i]){
            if(a[i+1]){
                tmp= min(a[i+1]/2,a[i]);
                ans+=tmp;
                a[i]-=tmp;
                a[i+1]-=(tmp*2);
                tmp= min(a[i]/2,a[i+1]);
                ans+=tmp;
                a[i]-=(tmp*2);
                a[i+1]-=tmp;
            }
            ans+= (a[i]/3);
            a[i]%=3;
            o+=a[i];
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef unsigned long long int ll;
const int N=5e5+5;
int n,a[N],lst,tmp;
ll ans,o,e;
queue <int> q;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if((a[i]%2)==0) e+=a[i];
        else{
            o+=1;
            e+= (a[i]-1);
            a[i]-=1;
        }
    }
    e/=2;
    if(o){
        ans= min(o,e);
        o-=ans;
        e-=ans;
    }
    if(e){
        e*=2;
        ans+= (e/3);
    }
    cout<<ans<<'\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
typedef long long int ll;
const int N=5e5+5;
ll n,a[N],lst,ans,o,e,tmp;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        o+=(a[i]%3);
    }
    for(int i=n-1;i>=0;i--){
        o-=(a[i]%3);
        if(o<=0) a[i]+=o;
        o=max(0ll,o); a[i]=max(0ll,a[i]);
        tmp= min(o,a[i]/2);
        a[i]-=(tmp*2);
        o-=tmp;
        ans+=tmp;
        ans+=(a[i]/3);
    }
    cout<<ans<<'\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5;
int a[maxn];
int n;
int main()
{
    cin>>n;
    long long ans=0;
    ios::sync_with_stdio(false);
    int cnt1=0,cnt2=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=a[i]/3;
        a[i]%=3;
        if(a[i]==1)cnt1++;
        if(a[i]==2)cnt2++;
    }
    ans+=min(cnt1,cnt2);
    cnt2-=min(cnt1,cnt2);
    ans+=cnt2*2/3;
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5;
int a[maxn];
int n;
int solve(int re){
    if(a[0]<re)return -1;
    int ans=(a[0]-re)/3;
    for(int i=1;i<n;i++){
        int t=a[i]-(3-re);
        if(t<0)re=a[i];
        else ans++,ans+=t/3,re=t%3;
    }
    return ans;
}
int main()
{
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        //ans+=a[i]/3;
        //a[i]=a[i]%3;
    }
    ans+=max(solve(0),max(solve(1),solve(2)));
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5;
int a[maxn];
int n;
int main()
{
    cin>>n;
    long long ans=0;
    int cnt1=0,cnt2=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        int p=min(a[i-1],a[i]/2);
        ans+=p;
        a[i]-=2*p;
        a[i-1]-=p;
        if(a[i]){
            ans+=a[i]/3;
            a[i]=a[i]%3;
        }
        a[i]+=a[i-1];
    }
    cout<<ans;
}