You are given a Young diagram. 

Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).

<image> Young diagram for a=[3,2,2,2,1].

Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.

Input

The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.

The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.

Output

Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.

Example

Input


5
3 2 2 2 1


Output


4

Note

Some of the possible solutions for the example:

<image> <image>
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.stream.Collectors;

public class Main {

    public  static  int c(int n,int m){
        int count=1;
        for(int i=1;i<=m;i++){
            count*=(n-i+1);
        }
        for(int i=2;i<=m;i++){
            count=count/i;
        }
        return count;
    }
    public static void reset(){
        System.out.println("R");
    }
    public  static boolean query(int x){
        Scanner cin = new Scanner(System.in);
        System.out.printf("? %d\n",x+1);
        String str=cin.next();
        char s[]=str.toCharArray();
        if(s[0]=='Y'){
            return true;
        }
        else{
            return false;
        }
    }
    public  static long dis(long x,long y,long x1,long y1){
        return Math.abs(x-x1)+Math.abs(y-y1);
    }
    static final char[] VALUES = { 'S', 'E', 'T' };

    static int[][][][]dp=new int[105][100][100][2];
    static int []num;


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n=cin.nextInt();
        int num[]=new int[n];
        for(int i=0;i<n;i++){
            num[i]=cin.nextInt();
        }

        long ans=0;
        boolean flag=false;
        int odd=0;


        for (int i = 0; i < n; i++) {

            ans += num[i] / 2;
            if (num[i] % 2 == 1 && flag) {
                flag = false;
                odd -= 1;
                ans++;
            } else if (num[i] % 2 == 1) {
                odd++;
                flag = true;
            } else {
                if (odd > 0)
                    flag = !flag;
                else
                    flag = false;
            }
        }
        System.out.println(ans);
    }
    public  static int slove(int idx,int odd,int even,int lst){
            if(odd<0||even<0){
                return Integer.MAX_VALUE;
            }
            if(idx==num.length){
                return 0;
            }
            if(dp[idx][odd][even][lst]!=0){
                return dp[idx][odd][even][lst];
            }
            int res=Integer.MAX_VALUE;
            if(num[idx]!=0){
                res=slove(idx+1,odd,even,num[idx]%2);
                res+=num[idx]%2==lst?0:1;
                dp[idx][odd][even][lst]=res;
            }
            else{
                res=slove(idx+1,odd-1,even,0);
                int r=slove(idx+1,odd,even-1,1);
                if(res!=Integer.MAX_VALUE)res+= lst==0?0:1;
                if(r!=Integer.MAX_VALUE) r+= lst==0?1:0;
                dp[idx][odd][even][lst]=Math.min(res, r);
            }
            return dp[idx][odd][even][lst];
        }
    public static String compute(String x,String y){
        StringBuilder result=new StringBuilder();
        for(int i=0;i<x.length();i++){
            char a=x.charAt(i);
            char b=y.charAt(i);

            char ch;
            if(a==b){
                ch=a;
            }
            else{
                for(int j=0;;j++){
                    if(VALUES[j]!=a&&VALUES[j]!=b){
                        ch=VALUES[j];
                        break;
                    }
                }
            }
            result.append(ch);
        }
        return result.toString();

    }
    }

			   		  	 	  			  				 					