Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements ai, ai + 1, ... , an or subtract 1 from all elements ai, ai + 1, ..., an. His goal is to end up with the array b1, b2, ..., bn. 

Of course, Wilbur wants to achieve this goal in the minimum number of steps and asks you to compute this value.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the length of the array ai. Initially ai = 0 for every position i, so this array is not given in the input.

The second line of the input contains n integers b1, b2, ..., bn ( - 109 ≤ bi ≤ 109).

Output

Print the minimum number of steps that Wilbur needs to make in order to achieve ai = bi for all i.

Examples

Input

5
1 2 3 4 5


Output

5

Input

4
1 2 2 1


Output

3

Note

In the first sample, Wilbur may successively choose indices 1, 2, 3, 4, and 5, and add 1 to corresponding suffixes.

In the second sample, Wilbur first chooses indices 1 and 2 and adds 1 to corresponding suffixes, then he chooses index 4 and subtract 1.
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    static final String NON_CHARACTER = "[^a-zA-Z]+";
    static final double EPS = 1e-9;
    static final int[] BOX_X = {0,-1,1,0}; //{-1,0,1,-1,1,-1,0,1};
    static final int[] BOX_Y = {-1,0,0,1}; //{-1,-1,-1,0,0,1,1,1};
    static InputReader reader;
    static OutputWriter writer;

    public static void main(String[] args)  {
        reader = new InputReader(System.in);
        writer = new OutputWriter(System.out);

        int n = reader.nextInt();
        int[] b = new int[n];
        for(int i=0;i<n;i++){
            b[i] = reader.nextInt();
        }
        long count = Math.abs(b[0]);
        for(int i=1;i<n;i++){
            if(b[i] != b[i-1]){
                count += Math.abs(b[i] - b[i-1]);
            }
        }
        writer.println(count);
        writer.flush();
    }
    static class Point implements Comparable<Point>{
        int x; int y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(Point o) {
            if(x == o.x){
                return y - o.y;
            }else{
                return x - o.x;
            }
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    return null;
                }
            }
            return tokenizer.nextToken();
        }
        public char nextChar(){
            try {
                char c = '\0';
                while(c == '\0' || c == '\n' || c == '\r')
                    c = (char) reader.read();
                return c;
            }catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public String nextLine(){
            if(tokenizer != null && tokenizer.hasMoreTokens()){
                StringBuilder sb = new StringBuilder(tokenizer.nextToken());
                while(tokenizer.hasMoreTokens()){
                    sb.append(" ").append(tokenizer.nextToken());
                }
                return sb.toString();
            }else{
                try {
                    return reader.readLine();
                }catch(Exception e){
                    return null;
                }
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

    static class OutputWriter {
        public BufferedWriter writer;
        OutputWriter(OutputStream stream) {
            writer = new BufferedWriter(new OutputStreamWriter(stream));
        }
        public void print(String string){
            try {
                writer.write(string, 0, string.length());
            }catch(Exception e){e.printStackTrace();}
        }
        public void print(char c){
            try {
                writer.write(c);
            }catch(Exception e){e.printStackTrace();}
        }
        public void print(String format, Object... args) {
            try {
                String string = String.format(format, args);
                writer.write(string, 0, string.length());
            }catch(Exception e){e.printStackTrace();}
        }
        public void print(int x){
            try {
                String string = String.format("%d", x);
                writer.write(string, 0, string.length());
            }catch(Exception e){e.printStackTrace();}
        }
        public void print(double x){
            try {
                int x_int = (int) (x * 100 + 1e-6); // add 1e-6 to avoid precision error when converting to int
                String string = String.format("%d.%02d", x_int/100, x_int%100);
                writer.write(string, 0, string.length());
            }catch(Exception e){e.printStackTrace();}
        }
        public void print(long x){
            try {
                String string = String.format("%d", x);
                writer.write(string, 0, string.length());
            }catch(Exception e){e.printStackTrace();}
        }
        public void println(String string){
            print(string);
            newline();
        }
        public void println(char c){
            print(c);
            newline();
        }
        public void println(String format, Object... args) {
            print(format, args);
            newline();
        }
        public void println(int x){
            print(x);
            newline();
        }
        public void println(long x){
            print(x);
            newline();
        }
        public void println(double x){
            print(x);
            newline();
        }
        public void println(){
            newline();
        }

        private void newline() {
            try {
                writer.newLine();
            }catch(Exception e){e.printStackTrace();}
        }
        private void flush(){
            try {
                writer.flush();
            }catch(Exception e){e.printStackTrace();}
        }
    }

    static class BitBoolean{
        final static int SIZE = 31;
        int[] bits;

        public BitBoolean(int size) {
            bits = new int[size/SIZE + 1];
        }

        public boolean equals(BitBoolean b){
            if (bits.length != b.bits.length)   return false;
            for (int i=0;i<bits.length;i++){
                if (bits[i] != b.bits[i])   return false;
            }
            return true;
        }

        public int set(int i, boolean b){
            return b ? setTrue(i) : setFalse(i);
        }
        public int setTrue(int i){
            return bits[i/SIZE] = BitBoolean.setBit(bits[i / SIZE], i % SIZE);
        }
        public int setFalse(int i){
            return bits[i/SIZE] = BitBoolean.clearBit(bits[i / SIZE], i % SIZE);
        }
        public boolean isTrue(int i){
            return BitBoolean.isOn(bits[i / SIZE], i%SIZE) > 0;
        }
        public int toggle(int i){
            return bits[i/SIZE] = BitBoolean.toggleBit(bits[i / SIZE], i % SIZE);
        }
        public void allTrue(){
            for (int i=0;i<bits.length;i++){
                bits[i] = BitBoolean.setAll(SIZE);
            }
        }
        public void allFalse(){
            for (int i=0;i<bits.length;i++){
                bits[i] = 0;
            }
        }

        static int setBit(int S, int j) { return S | (1 << j); }

        static int isOn(int S, int j) { return S & (1 << j); }

        static int clearBit(int S, int j) { return S & ~(1 << j); }

        static int toggleBit(int S, int j) { return S ^ (1 << j); }

        static int lowBit(int S) { return S & (-S); }

        static int setAll(int n) { return (1 << n) - 1; }

        static int modulo(int S, int N) { return ((S) & (N - 1)); } // returns S % N, where N is a power of 2

        static int isPowerOfTwo(int S) { return (S & (S - 1)) == 0 ? 1 : 0; }

        static int nearestPowerOfTwo(int S) { return ((int)Math.pow(2.0, (int)((Math.log((double)S) / Math.log(2.0)) + 0.5))); }

        static int turnOffLastBit(int S) { return ((S) & (S - 1)); }

        static int turnOnLastZero(int S) { return ((S) | (S + 1)); }

        static int turnOffLastConsecutiveBits(int S) { return ((S) & (S + 1)); }

        static int turnOnLastConsecutiveZeroes(int S) { return ((S) | (S - 1)); }

        static void printSet(int vS) {             // in binary representation
            System.out.printf("S = %2d = ", vS);
            Stack<Integer> st = new Stack<Integer>();
            while (vS > 0) {
                st.push(vS % 2);
                vS /= 2;
            }
            while (!st.empty()) {                          // to reverse the print order
                System.out.printf("%d", st.peek());
                st.pop();
            }
            System.out.printf("\n");
        }
    }

    /**
     * Permuatations
     */

    // simply prints all permutation - to see how it works
    private static void printPermutations( Comparable[] c ) {
        System.out.println( Arrays.toString( c ) );
        while ( ( c = nextPermutation( c ) ) != null ) {
            System.out.println( Arrays.toString( c ) );
        }
    }

    // modifies c to next permutation or returns null if such permutation does not exist
    private static Comparable[] nextPermutation( final Comparable[] c ) {
        // 1. finds the largest k, that c[k] < c[k+1]
        int first = getFirst( c );
        if ( first == -1 ) return null; // no greater permutation
        // 2. find last index toSwap, that c[k] < c[toSwap]
        int toSwap = c.length - 1;
        while ( c[ first ].compareTo( c[ toSwap ] ) >= 0 )
            --toSwap;
        // 3. swap elements with indexes first and last
        swap( c, first++, toSwap );
        // 4. reverse sequence from k+1 to n (inclusive)
        toSwap = c.length - 1;
        while ( first < toSwap )
            swap( c, first++, toSwap-- );
        return c;
    }

    // finds the largest k, that c[k] < c[k+1]
    // if no such k exists (there is not greater permutation), return -1
    private static int getFirst( final Comparable[] c ) {
        for ( int i = c.length - 2; i >= 0; --i )
            if ( c[ i ].compareTo( c[ i + 1 ] ) < 0 )
                return i;
        return -1;
    }

    // swaps two elements (with indexes i and j) in array
    private static void swap( final Comparable[] c, final int i, final int j ) {
        final Comparable tmp = c[ i ];
        c[ i ] = c[ j ];
        c[ j ] = tmp;
    }

    private static int length(long num){
        int count = 0;
        while(num > 0){
            count ++;
            num /= 10;
        }
        return count;
    }
    private static int length(int num){
        int count = 0;
        while(num > 0){
            count ++;
            num /= 10;
        }
        return count;
    }

    static abstract class Combination<T>{
        T[] array, a;
        int size, n;

        @SuppressWarnings("unchecked")
        public Combination(Class<T> c, T[] array, int size, int n) {
            this.array = array;
            this.size = size;
            this.n = n;
            a = (T[]) Array.newInstance(c, n);
        }
        public void generate(){
            g(array, a, 0, 0, n);
        }
        private void g(T[] set, T[] a, int i, int j, int n){
            if (i == n){
                solve(a);
                return;
            } else if(set.length - j < n - i){
                return;
            } else {
                for (int p = j; p < set.length; p++) {
                    a[i] = set[p];
                    g(set, a, i + 1, p + 1, n);
                }
            }
        }
        public abstract void solve(T[] a);
    }
    //    static class FenwickTree {
//        private Vector<Integer> ft;
//
//        private int LSOne(int S) { return (S & (-S)); }
//
//        public FenwickTree() {}
//
//        // initialization: n + 1 zeroes, ignore index 0
//        public FenwickTree(int n) {
//            ft = new Vector<Integer>();
//            for (int i = 0; i <= n; i++) ft.add(0);
//        }
//
//        public int rsq(int b) {                              // returns RSQ(1, b)
//            int sum = 0;
//            for (; b > 0; b -= LSOne(b)) sum += ft.get(b);
//            return sum;
//        }
//
//        public int rsq(int a, int b) {                       // returns RSQ(a, b)
//            return rsq(b) - (a == 1 ? 0 : rsq(a - 1)); }
//
//        // adjusts value of the k-th element by v (v can be +ve/inc or -ve/dec)
//        public void adjust(int k, int v) {                    // note: n = ft.size() - 1
//            for (; k < (int)ft.size(); k += LSOne(k))
//                ft.set(k, ft.get(k) + v);
//        }
//
//        public int readSingle(int idx){ //get single value at index idx
//            int sum = ft.get(idx); // sum will be decreased
//            if (idx > 0){ // special case
//                int z = idx - (idx & -idx); // make z first
//                idx--; // idx is no important any more, so instead y, you can use idx
//                while (idx != z){ // at some iteration idx (y) will become z
//                    sum -= ft.get(idx);
//                    idx -= (idx & -idx);
//                }
//            }
//            return sum;
//        }
//        public void scale(int c){   //scale all entry by a value
//            for(int i=0;i<ft.size();i++)
//                ft.set(i, ft.get(i) * c);
//        }
//        // if in tree exists more than one index with a same
//        // cumulative frequency, this procedure will return
//        // some of them (we do not know which one)
//        int find(int cumFre){
//            int idx = 0; //result of function
//            int bitMask = 1;
//            int f = ft.size();
//            while(f>1) {
//                f >>= 1;
//                bitMask <<= 1;
//            }
//            while ((bitMask != 0) && (idx < ft.size())){ // nobody likes overflow :)
//                int tIdx = idx + bitMask; // we make midpoint of interval
//                if (cumFre == ft.get(tIdx)) // if it is equal, we just return idx
//                    return tIdx;
//                else if (cumFre > ft.get(tIdx)){
//                    // if tree frequency "can fit" into cumFre,
//                    // then include it
//                    idx = tIdx; // update index
//                    cumFre -= ft.get(tIdx); // set frequency for next loop
//                }
//                bitMask >>= 1; // half current interval
//            }
//            if (cumFre != 0) // maybe given cumulative frequency doesn't exist
//                return -1;
//            else
//                return idx;
//        }
//    }
    public static class SuffixArray {
        private Suffix[] suffixes;

        /**
         * Initializes a suffix array for the given <tt>text</tt> string.
         * @param text the input string
         */
        public SuffixArray(String text) {
            int N = text.length();
            this.suffixes = new Suffix[N];
            for (int i = 0; i < N; i++)
                suffixes[i] = new Suffix(text, i);
            Arrays.sort(suffixes);
        }

        private static class Suffix implements Comparable<Suffix> {
            private final String text;
            private final int index;

            private Suffix(String text, int index) {
                this.text = text;
                this.index = index;
            }
            private int length() {
                return text.length() - index;
            }
            private char charAt(int i) {
                return text.charAt(index + i);
            }

            public int compareTo(Suffix that) {
                if (this == that) return 0;  // optimization
                int N = Math.min(this.length(), that.length());
                for (int i = 0; i < N; i++) {
                    if (this.charAt(i) < that.charAt(i)) return -1;
                    if (this.charAt(i) > that.charAt(i)) return +1;
                }
                return this.length() - that.length();
            }

            public String toString() {
                return text.substring(index);
            }
        }

        /**
         * Returns the length of the input string.
         * @return the length of the input string
         */
        public int length() {
            return suffixes.length;
        }


        /**
         * Returns the index into the original string of the <em>i</em>th smallest suffix.
         * That is, <tt>text.substring(sa.index(i))</tt> is the <em>i</em>th smallest suffix.
         * @param i an integer between 0 and <em>N</em>-1
         * @return the index into the original string of the <em>i</em>th smallest suffix
         * @throws java.lang.IndexOutOfBoundsException unless 0 &le; <em>i</em> &lt; <Em>N</em>
         */
        public int index(int i) {
            if (i < 0 || i >= suffixes.length) throw new IndexOutOfBoundsException();
            return suffixes[i].index;
        }


        /**
         * Returns the length of the longest common prefix of the <em>i</em>th
         * smallest suffix and the <em>i</em>-1st smallest suffix.
         * @param i an integer between 1 and <em>N</em>-1
         * @return the length of the longest common prefix of the <em>i</em>th
         * smallest suffix and the <em>i</em>-1st smallest suffix.
         * @throws java.lang.IndexOutOfBoundsException unless 1 &le; <em>i</em> &lt; <em>N</em>
         */
        public int lcp(int i) {
            if (i < 1 || i >= suffixes.length) throw new IndexOutOfBoundsException();
            return lcp(suffixes[i], suffixes[i-1]);
        }

        // longest common prefix of s and t
        private static int lcp(Suffix s, Suffix t) {
            int N = Math.min(s.length(), t.length());
            for (int i = 0; i < N; i++) {
                if (s.charAt(i) != t.charAt(i)) return i;
            }
            return N;
        }

        /**
         * Returns the <em>i</em>th smallest suffix as a string.
         * @param i the index
         * @return the <em>i</em> smallest suffix as a string
         * @throws java.lang.IndexOutOfBoundsException unless 0 &le; <em>i</em> &lt; <Em>N</em>
         */
        public String select(int i) {
            if (i < 0 || i >= suffixes.length) throw new IndexOutOfBoundsException();
            return suffixes[i].toString();
        }

        /**
         * Returns the number of suffixes strictly less than the <tt>query</tt> string.
         * We note that <tt>rank(select(i))</tt> equals <tt>i</tt> for each <tt>i</tt>
         * between 0 and <em>N</em>-1.
         * @param query the query string
         * @return the number of suffixes strictly less than <tt>query</tt>
         */
        public int rank(String query) {
            int lo = 0, hi = suffixes.length - 1;
            while (lo <= hi) {
                int mid = lo + (hi - lo) / 2;
                int cmp = compare(query, suffixes[mid]);
                if (cmp < 0) hi = mid - 1;
                else if (cmp > 0) lo = mid + 1;
                else return mid;
            }
            return lo;
        }

        // compare query string to suffix
        private static int compare(String query, Suffix suffix) {
            int N = Math.min(query.length(), suffix.length());
            for (int i = 0; i < N; i++) {
                if (query.charAt(i) < suffix.charAt(i)) return -1;
                if (query.charAt(i) > suffix.charAt(i)) return +1;
            }
            return query.length() - suffix.length();
        }
    }
}
