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.util.StringTokenizer;

public class BTask {
    private static final String QUICK_ANSWER = "NO";
    private final Input in;
    private final StringBuilder out;

    public BTask(Input in, StringBuilder out) {
        this.in = in;
        this.out = out;
    }

    public void solve() throws QuickAnswer {
        int n = nextInt();
        int[] a = nextInts(n);
        long cnt = 0;
        int pos = -1;
        int c = 0;
        for (int i : a) {
            while (c * 2 - 1 + pos > i) --c;
            if (c == 0) pos = -1;
            if (pos == -1) {
                cnt += i / 2;
                if (i % 2 == 1) {
                    pos = 0;
                    c = 1;
                }
                continue;
            }
            cnt += i / 2;
            if (pos == 0) {
                if (i % 2 == 1) {
                    ++cnt;
                    if (--c == 0) pos = -1;
                    else pos = 1;
                } else pos = 1;
                continue;
            }
            pos = 0;
            if (i % 2 == 1) {
                ++c;
            }
        }
        print(cnt);
    }

    // Common functions

    private static class Input {
        private final BufferedReader in;
        private StringTokenizer tokenizer = null;

        public Input(BufferedReader in) {
            this.in = in;
        }

        String nextToken() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        String nextLine() {
            try {
                return in.readLine();
            } catch (IOException e) {
                return "";
            }
        }
    }

    void quickAnswer(String answer) throws QuickAnswer {
        throw new QuickAnswer(answer);
    }

    void quickAnswer() throws QuickAnswer {
        quickAnswer(QUICK_ANSWER);
    }


    static class QuickAnswer extends Exception {
        private String answer;

        public QuickAnswer(String answer) {
            this.answer = answer;
        }
    }

    void print(Object... args) {
        String prefix = "";
        for (Object arg : args) {
            out.append(prefix);
            out.append(arg);
            prefix = " ";
        }
    }

    void println(Object... args) {
        print(args);
        out.append("\n");
    }

    void printsp(Object... args) {
        print(args);
        out.append(" ");
    }

    int nextInt() {
        return in.nextInt();
    }

    long nextLong() {
        return in.nextLong();
    }

    String nextString() {
        return in.nextLine();
    }

    int[] nextInts(int count) {
        int[] res = new int[count];
        for (int i = 0; i < count; ++i) {
            res[i] = nextInt();
        }
        return res;
    }

    int[][] nextInts(int count, int n) {
        int[][] res = new int[n][count];
        for (int i = 0; i < count; ++i) {
            for (int j = 0; j < n; j++) {
                res[j][i] = nextInt();
            }
        }
        return res;
    }

    long[] nextLongs(int count) {
        long[] res = new long[count];
        for (int i = 0; i < count; ++i) {
            res[i] = nextLong();
        }
        return res;
    }

    long[][] nextLongs(int count, int n) {
        long[][] res = new long[n][count];
        for (int i = 0; i < count; ++i) {
            for (int j = 0; j < n; j++) {
                res[j][i] = nextLong();
            }
        }
        return res;
    }

    public static void main(String[] args) {
        doMain(System.in, System.out);
    }

    static void doMain(InputStream inStream, PrintStream outStream) {
        Input in = new Input(new BufferedReader(new InputStreamReader(inStream)));
        StringBuilder totalOut = new StringBuilder();
        int count = 1;
        //count = in.nextInt();
        while (count-- > 0) {
            try {
                StringBuilder out = new StringBuilder();
                new BTask(in, out).solve();
                totalOut.append(out.toString());
            } catch (QuickAnswer e) {
                totalOut.append(e.answer);
            }
            if (count > 0) {
                totalOut.append("\n");
            }
        }
        outStream.print(totalOut.toString());
    }
}

