jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                int K = scan.nextInt();
                int[] d = new int[K+1];
                ArrayList<Integer> arrayList = new ArrayList<Integer>();
                
                for(int i=1; i<=K;i++){
                    d[i] = scan.nextInt();
                        for(int j=1; j<=d[i];j++){
                            int[][] A = new int[K+1][d[i]+1];
                            A[i][j] = scan.nextInt();
                            arrayList.add(A[i][j]);
                        }
                }
                
                ArrayList<Integer> listB = new ArrayList<Integer>(new HashSet<>(arrayList));

                System.out.println(N-listB.size());
      
        }
}
//  [java]
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        ArrayList<String> param = new ArrayList<String>();
        
        for (int i = 0; i < k; i++) {
            int num = sc.nextInt();
            for (int h = 0; h < num; h++) {
                String input = sc.next();
                param.add(input);
            }
        }
        
        int fc = 0;
        for (int i = 1; i <= n; i++) {
            int count = 0;
            for (int h = 0; h < param.size(); h++) {
                
                if (Integer.parseInt(param.get(h)) == i) {
                    count++;
                }
            }
            if (count == 0) {
                fc++;
            }
        }
        
        System.out.println(fc);
    }
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int[] okashi = new int[N];

        for (int i = 0; i < K; i++) {
            int d = scanner.nextInt();
            for (int j = 0; j < d; j++) {
                int A = scanner.nextInt();
                okashi[A-1]++;
            }
        }

        System.out.println(Arrays.stream(okashi).filter(i -> i == 0).count());
    }
}
//  [cpp]
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int prime[20000000];
int a[300001];
map<int, int> mp;
vector<int> pr;
void sieve(int n)
{

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == 0)
        {

            for (int i = p * p; i <= n; i += p)
                prime[i] = p;
        }
    }
    for (int i = 2; i <= 20000000;i++){
        if(prime[i]==0)
            pr.pb(i);
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    sieve(20000000);
    //cin >> tc;
    while (tc--)
    {
        int n, m;
        cin >> n >> m;
        set<int> se;
        for (int i = 0; i < m;i++){
            int d;
            cin >> d;
            int a;
            for (int j = 0; j < d;j++){
                cin >> a;
                se.insert(a);
            }
        }
        int f = (int)se.size();
        cout << n - f << endl;
    }

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<< '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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



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

int n, k;
cin >> n >> k;

map<ll, ll> mm;

rep(i,k){
  int a;
  cin >> a;
  debug(a);
  rep(j, a) {
    int b;
    cin >> b;

    mm[b]++;
    debug2(b,mm[b]);
  }
}

debug(mm[2]);

int sum = 0;
REP(i, n) {
  debug(mm[i]);
  if (mm[i] == 0) {
    sum++;
  };
}

cout << sum << endl;

return 0;
}
//  [c]
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int compare_base(const void *b, const void *f) {
  return (*(int *)b - *(int *)f);
}

int main(void) {
  int scan; // scanf result
  int *answer; // to output 
  int n; // to input 
  int k; // to input 
  int *d;
  int **ad;
  int count;

  scan = scanf("%d", &n);
  scan = scanf("%d", &k);

  d = (int *)malloc(sizeof(int) * k);
  ad = (int **)malloc(sizeof(int *) * k);
  for (int i = 0; i < k; i++) {
    scan = scanf("%d", &d[i]);
    ad[i] = (int *)malloc(sizeof(int) * d[i]);
    for (int m = 0; m < d[i]; m++) {
      scan = scanf("%d", &ad[i][m]);
    }
  }

  int dsum = 0;
  for (int i = 0; i < k; i++) {
      dsum += d[i];
  }

//  printf("dsum: %d\n", dsum);

  answer = (int *)malloc(sizeof(int) * k * dsum);
  count = 0; 
  for (int y = 0; y < k; y++) {
    for (int x = 0; x < d[y]; x++) {
      answer[count] = ad[y][x];
      count++;
    }
  }
  
  qsort(answer, k * dsum, sizeof(int), compare_base);

//  for (int i = 0; i < k * dsum; i++) {
//    printf("a: %d\n", answer[i]);
//  }

  int answercount = 0;
  for (int i = 0; i < k * dsum; i++) {
    if ((i == 0 || (i >= 1 && answer[i - 1] != answer[i])) && answer[i] != 0) {
      answercount++;
    }
  }

//  printf("answer count: %d\n", answercount); 

  printf("%d", (n - answercount));
  return (0);
}
//  [c]
#include <stdio.h>

int		main(void)
{
	// int sunuke[101];
	int Aarray[10010];
	int i, j, N, K, d, ar_idx, tmp;
	int num_ct = 0;

	ar_idx = 0;
	scanf("%d %d", &N, &K);
	for (i = 0; i < K * 2; i++)
	{
		if (i % 2 == 0)
		{
			scanf ("%d", &d);
		}
		else
		{
			for (j = 0; j < d; j++)
			{
				scanf("%d", &Aarray[ar_idx + j]);
			}
			ar_idx += j;
		}
	}

	for (i=0; i<ar_idx; ++i) {
	    for (j=i+1; j<ar_idx; ++j) {
	      if (Aarray[i] > Aarray[j]) {
	        tmp =  Aarray[i];
	        Aarray[i] = Aarray[j];
	        Aarray[j] = tmp;
	      }
	    }
	}

	tmp = Aarray[0];
	num_ct++;
	// sunuke[num_ct] = Aarray[0];
	for (i = 1; i < ar_idx; i++)
	{
		if (tmp != Aarray[i])
		{
			num_ct++;
			// sunuke[num_ct] = Aarray[i];
		}
		tmp = Aarray[i];
	}
	printf("%d",N - num_ct);
	// for (i = 0; i < ar_idx; i++)
	// {
	// 	printf("%d", Aarray[i]);
	// }

	return (0);
}
//  [c]
#include<stdio.h>

int jdg_sunuke(int *num, int *data);
int count(int *num, int *data);

int main(void)
{
  int all_num;
  int snack_num;
  int sunuke_num;
  int jdg[100] = {0};
  int cntnum;
  int i;
  
  scanf("%d %d^n", &all_num, &snack_num);
  
  for(i = 0; i < (snack_num*2); i++)
  {
    scanf("%d\n", &sunuke_num);
    jdg_sunuke(&sunuke_num, jdg);
  }
  
  cntnum = count(&all_num, jdg);
  
  printf("%d\n", all_num-cntnum );
}

int jdg_sunuke(int *num, int *data)
{
  int i;
  int temp_num;
  
  for(i = 0;i < *num; i++)
  {
    scanf("%d ", &temp_num);
    data[temp_num-1] = 1;
  }
  
  return 0;
}

int count(int *num, int *data)
{
  int i;
  int outnum = 0;
  
  for(i = 0; i < *num; i++)
  {
    if(data[i] == 1)
    {
      outnum++;
    }
    else
    {
    }
  }
  
  return outnum;
}
//  [javascript]
function main(input) {
  const inputs = input.split('\n')
  const [N, K] = inputs[0].split(' ').map(Number)
  const su = Array.from(new Array(N + 1))
  for(let i = 1; i <= K * 2; i += 2) {
    const d = inputs[i]
    const Ai = inputs[i+1].split(' ')
    // console.log(d, Ai)
    Ai.forEach(e => {
      su[e] = true
    })
  }
  // console.log(su)
  console.log(
    su.slice(1).reduce((h, e) => {
      return e === undefined ? h + 1 : h
    }, 0)
  )
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function main(input) {
  const args = input.split("\n");
  const [N, K] = args[0].split(" ").map((n) => parseInt(n, 10));
  const sunukes = new Array(N).fill(false);

  for (let i = 2; i <= K * 2; i += 2) {
    args[i].split(" ").map((n) => parseInt(n, 10))
      .map((A) => { sunukes[A - 1] = true; });
  }

  console.log(sunukes.reduce((num, sunuke) => (sunuke ? num : num + 1), 0));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, k] = spi[0].split(' ').map(e => Number(e));

    const snukes = new Array(n);
    for (let i = 0; i < n; i++) snukes[i] = 0;

    let row = 1;
    for (let i = 0; i < k; i++) {
        const d = Number(spi[row]);
        row++;
        const a = spi[row].split(' ').map(e => Number(e));
        row++;
        for (let j = 0; j < d; j++) {
            snukes[a[j] - 1]++;
        }
    }

    let ans = 0;
    for (let i = 0; i < n; i++) {
        if (snukes[i] === 0) ans++;
    }

    console.log(ans);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	N := list[0]
	K := list[1]
	d := make([]int, K)
	A := make([][]int, K)
	X := make([]int, N) // すぬけ君
	for i := 0; i < K; i++ {
		d[i] = getStdinInt()
		A[i] = getStdinIntArr()
	}

	for i := 0; i < K; i++ {
		for j := 0; j < d[i]; j++ {
			X[A[i][j]-1]++
		}
	}

	ans := 0
	for i := 0; i < N; i++ {
		if X[i] == 0 {
			ans++
		}
	}

	fmt.Printf("%d\n", ans)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 1024*1024*10)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	N := list[0]
	K := list[1]
	d := make([]int, K)
	A := make([][]int, K)
	X := make([]int, N) // すぬけ君
	for i := 0; i < K; i++ {
		d[i] = getStdinInt()
		A[i] = getStdinIntArr()
		for j := 0; j < d[i]; j++ {
			X[A[i][j]-1]++
		}
	}

	ans := 0
	for i := 0; i < N; i++ {
		if X[i] == 0 {
			ans++
		}
	}

	fmt.Printf("%d\n", ans)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 1024*1024*10)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
//  [go]
package main

import (
	f "fmt"
)

func main() {
	var N, K int
	f.Scanf("%d %d", &N, &K)

	var d, s int
	A := make([]int, N)
	for i := 0; i < K; i++ {
		f.Scanf("%d", &d)
		for j := 0; j < d; j++ {
			f.Scanf("%d", &s)
			A[s-1] = 1
		}
	}

	var count int
	for i := 0; i < N; i++ {
		if A[i] == 0 {
			count++
		}
	}

	f.Println(count)
}
//  [ruby]
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
ans = Set.new
k.times do
  d = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  ans += Set.new(a)
end

puts n - ans.size
//  [ruby]
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

n,k = inp
t = na(n,false)
k.times do
  d = inp[0]
  inp.each do |x|
    t[x-1] = true
  end
end
p t.count(false)
//  [ruby]
require 'pp'

n, k = gets.split.map(&:to_i)
memo = Hash.new(0)
k.times do |i|
    d = gets.to_i
    a_d = gets.split.map(&:to_i)
    
    a_d.each do |a|
        memo[a] += 1
    end
end

puts n - memo.keys.length
//  [rust]
use proconio::input;
use proconio::marker::{Chars};
use std::iter::Iterator;
use std::collections::HashSet;

fn main() {
    input! {
    n: i32,
    k: i32,
    }
    let mut ans = 0;
    let mut sunuke = vec![0; n as usize];

    dbg!(&n);
    dbg!(&k);
    dbg!(&sunuke);

    for i in 1..=k {
        input! {
            d: i32,
            a: [i32; d],
            }
        
        dbg!(&d);
        dbg!(&a);
        
        for s in a {
            dbg!(&s);
            sunuke[(s - 1) as usize] =  sunuke[(s - 1) as usize] + 1;
        }
    }

    for v in sunuke {
        if v == 0{
            ans = ans + 1;
        }
    }

     println!("{}", ans);
}
//  [swift]
let (n,k) = cin.pair
var sset = Set<Int>()
let array: [Int] = Array((1...k).map { _ -> [Int] in 
    _ = cin.int
    return cin.array
}.joined())

print(
    (1...n).filter { !array.contains($0) }.count
)

// MARK: #### 以下、ライブラリ ####

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var int: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var str: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { str.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { str.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in int } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence }
infix operator ^^ : PowerPrecedence
func ^^ (radix: Int, power: Int) -> Int {
    return Int(pow(Double(radix), Double(power)))
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}
//  [swift]
import Foundation

var input = readLine()!.split(separator: " ")
var n = Int(input[0])!
var k = Int(input[1])!

var snuke = [Bool](repeating: false, count: n)

for _ in 0 ..< k {
    _ = Int(readLine()!)!
    let snacks = readLine()!.split(separator: " ").map({Int($0)!});
    for i in snacks {
        snuke[i-1] = true;
    }
}

var ans = 0
for i in snuke { ans += i ? 0 : 1 }

print(ans)
//  [swift]
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")

let n = Int(split[0])!
let k = Int(split[1])!

var nArray = Array(repeating: 0, count: n)
var kArray: [String] = []

for _ in 0..<k {
    let input_line2: String = readLine()!
    let d = Int(input_line2)!
    
    let input_line3: String = readLine()!
    let split3: [String] = input_line3.components(separatedBy: " ")
    
    for i in 0..<d {
        kArray.append(split3[i])
    }
}

let uniqueValues = Array(Set(kArray))

let ans = nArray.count - uniqueValues.count

print(ans)
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, K] = input[0].map(Number);

  const Sunukes = Array<boolean>().fill(false);
  let answer = N;

  for (let i = 1; i <= K * 2; i += 2) {
    const A = input[i + 1].map(Number);

    A.forEach((a) => {
      if (!Sunukes[a]) {
        Sunukes[a] = true;
        answer -= 1;
      }
    });
  }

  return answer;
};

console.log(main(read()));
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, K] = input[0].map(Number);

  const sunukes: boolean[] = [];
  let answer = N;

  for (let i = 1; i <= K * 2; i += 2) {
    const A = input[i + 1].map(Number);

    A.forEach((a) => {
      if (!sunukes[a]) {
        sunukes[a] = true;
        answer -= 1;
      }
    });
  }

  return answer;
};

console.log(main(read()));
//  [python]
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
abs_A = [abs(i) for i in A]
ans = 0
if (0 in A) or (np.count_nonzero(A<0) % 2 == 0):
    ans = sum(abs_A)
else:
    ans = sum(abs_A) - 2*min(abs_A)
print(ans)
//  [python]
import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
INF = 10 ** 18
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()
N = len(A_li)

@lru_cache(maxsize=None)
def dp(i,j):
    if i == 0:
        if j == 0: return 0
        elif j == 1: return -INF
    else:
        if j == 0: return max(dp(i-1,0) + A_li[i-1], dp(i-1,1) - A_li[i-1])
        if j == 1: return max(dp(i-1,0) - A_li[i-1], dp(i-1,1) + A_li[i-1])

print(dp(N,0))
//  [python]
import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
INF = 10 ** 18

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()
N = len(A_li)

@lru_cache(maxsize=None)
def dp(i,j):
    if i == 0:
        if j == 0: return A_li[0]
        elif j == 1: return -A_li[0]
    else:
        if j == 0: return max(dp(i-1, 0) + A_li[i], dp(i-1, 1) - A_li[i])
        elif j == 1: return max(dp(i-1, 0) - A_li[i], dp(i-1, 1) + A_li[i])

print(dp(N-1,0))
//  [java]
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static long[] maxPas = new long[5];
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] A = new double[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextDouble();
		}
		//　偶数だったら、すべてプラスにできる
		//　奇数だったら、一つだけマイナスにできる
		int minusCnt = 0;
		for(int i=0; i<N; i++) {
			if(A[i] < 0) {
				minusCnt ++;
			}
		}
		
		double ans = 0;
		double[] absA = new double[N];
		for(int i=0; i<N; i++) {
			absA[i] = Math.abs(A[i]);
		}
		if(minusCnt % 2 == 0) {
			for(int i=0; i<N; i++) {
				ans += absA[i];
			}
		} else {
			Arrays.sort(absA);
			ans -= absA[0];
			for(int i=1; i<N; i++) {
				ans += absA[i];
			}
		}
		
		System.out.println(BigDecimal.valueOf(Math.round(ans)).toPlainString());
	}
}
//  [java]
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int N = std.nextInt();
        int[] A = IntStream.range(0, N).map(it -> std.nextInt()).toArray();
        long minusCount = Arrays.stream(A).filter(it -> it < 0).count();
//        long BMax = 0;
        BigInteger BMax = BigInteger.valueOf(0L);
        if (minusCount % 2 == 0) {
            int[] s = Arrays.stream(A).map(Math::abs).toArray();
            for (int i = 0; i < s.length; i++) {
                BMax = BMax.add(BigInteger.valueOf(s[i]));
            }
        } else {
            int[] arrays = Arrays.stream(A).map(Math::abs).sorted().toArray();
            int min = arrays[0];
            for (int i = 1; i < arrays.length; i++) {
                BMax = BMax.add(BigInteger.valueOf(arrays[i]));
            }

            BMax = BMax.subtract(BigInteger.valueOf(min));
        }

        System.out.println(BMax.toString());
    }
}
//  [java]
import java.util.*;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int minuscount = 0;
		List<Integer> values = new ArrayList<Integer>();
		for(int tmp = 0; tmp < n; tmp++) {
			int v = sc.nextInt();
			if(v < 0) {
				minuscount++;
			}
			values.add(Math.abs(v));
		}
		long result = 0;
		if((n % 2 == 1) && (minuscount % 2 == 0)) {
			for(Integer value : values) {
				result += value;
			}
		}else if((n % 2 == 1) && (minuscount % 2 == 1)) {
			int min = values.stream().min(Comparator.comparing(Integer::valueOf)).orElse(0);
			values.remove(values.indexOf(min));
			for(Integer value : values) {
				result += value;
			}
			result -= min;
		}else if((n % 2 == 0) && (minuscount % 2 == 0)) {
			for(Integer value : values) {
				result += value;
			}
		}else {
			int min = values.stream().min(Comparator.comparing(Integer::valueOf)).orElse(0);
			values.remove(values.indexOf(min));
			for(Integer value : values) {
				result += value;
			}
			result -= min;
		}
		System.out.println(result);	
	}
}
//  [cpp]
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e18,cnt,flag;

ll b[100000],idx;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		if(a[i]<=0) b[idx++]=i;
	}
	for(ll i=0; i<n; i++){
		if(a[i]<0){
			bool ok=false;
			for(ll j=0; j<idx; j++){
				if(b[j]>i){
					a[i]=abs(a[i]);
					a[b[j]]=abs(a[b[j]]);
					ok=true;
					break;
				}
			}
			if(ok==false){
				for(ll j=0; j<n; j++){
					if(abs(a[j])<mn){
						flag=j;
						mn=abs(a[j]);
					}
				}
				a[i]=abs(a[i]);
				a[flag] *=-1;
			}
		}
	}
	for(ll i=0; i<n; i++){
		sum+=a[i];
	}
	cout<<sum;
}
//  [cpp]
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


// aとbの最大公約数
ll gcd(ll a, ll b) {
	if (a < b) gcd(b, a);
	ll r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

signed main(){

	int N;
	vector<int> A;
	cin >> N;
	A.resize(N);
	rep(i, N) cin >> A[i];

	sort(A.begin(), A.end());

	int m = INF;
	for (int i = 0; i*2 <= N; i++){
		// 2*i個の和
		int t = 0;
		for (int j = 0; j < 2 * i; j++)
			t += A[j];
		m = min(m, t);
	}

	int ans = 0;
	rep(i, N) ans += A[i];
	ans += abs(m) * 2;

	cout << ans << endl;
	

	return 0;
}
//  [cpp]
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x) cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x) cout << ((x) ? "YES" : "NO") << endl

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	ll a[n];
	bool isodd = false;
	ll minimum = 1000000000;
	ll ret = 0;
	rep(i, n) {
		cin >> a[i];
		if(a[i] < 0) {
			isodd = !isodd;
			a[i] = -a[i];
		}
		debug(isodd);
		if(a[i] < minimum) minimum = a[i];
		ret += a[i];
	}

	if(isodd) {
		ret -= 2 * minimum;
	}

	cout << ret << endl;

	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define PI 3.14159265358979323846264338327950L
int main(){
    int n,i;
    scanf("%d",&n);
    ll int a[n],sum=0,min=1000000010,minus=0,zero=0;
    rep(i,n){
        scanf("%lld",&a[i]);
        if(abs(a[i])<min) min=abs(a[i]);
        if(a[i]<0) minus++;
        if(a[i]==0) zero=1;
        sum+=abs(a[i]);
    }
    if(zero==1||minus%2==0){
        printf("%lld",sum);
    }else{
        printf("%lld",sum-2*min);
    }
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long zero = 0;
  long minus = 0;
  long sum = 0;
  for (long i = 0; i < n; i++) {
    if (a[i] == 0) {
      zero++;
    }
    if (a[i] < 0) {
      minus++;
      a[i] *= -1;
    }
    sum += a[i];
  }
  if (zero != 0 || minus%2 == 0) {
    printf("%ld\n", sum);
    return 0;
  }
  qsort(a, n, sizeof(long), cmpnum);
  sum -= a[0]*2;
  printf("%ld\n", sum);

  return 0;
}
//  [c]
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],cnt=0,i;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]<0)cnt++;
    }long long ans=0;
    for(i=0;i<n;i++){
        a[i]=abs(a[i]);
        ans+=a[i];
    }
    
    if(cnt%2==1){
        qsort(a,n,sizeof(int),compare);
        ans-=2*a[0];
    }
    printf("%lld",ans);
    return 0;
}
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var x = 0;
  var z = 0;
  var ans = 0;
  var mn = 9e9;
  for(var i = 0; i < n; i++){
    if(a[i] < 0)x++;
    else if(a[i] === 0)z++;
    var t = Math.abs(a[i]);
    ans += t;
    if(t < mn)mn = t;
  }
  if(z || x % 2 === 0)return ans;
  return ans - mn*2;
}
//  [javascript]
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), A = cin.getIntArray(N);
    let dp = new Array(N + 1).fill(0).map(() => new Array(2).fill(-1e10));
    dp[0][0] = 0;
    for (let n = 0; n < N; n++) {
        dp[n + 1][0] = Math.max(...[dp[n + 1][0], dp[n][0] + A[n], dp[n][1] - A[n]]);
        dp[n + 1][1] = Math.max(...[dp[n + 1][1], dp[n][0] - A[n], dp[n][1] + A[n]]);
    }
    console.log(dp[N][0]);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt();
    let A = cin.getIntArray(N);
    let dp = new Array(N+1).fill(0).map(() => new Array(2).fill(Number.MIN_SAFE_INTEGER));
    dp[0][0] = 0;
    for (let n = 0; n < N; n++) {
        dp[n+1][0] = Math.max(...[dp[n+1][0], dp[n][0] + A[n], dp[n][1] - A[n]]);
        dp[n+1][1] = Math.max(...[dp[n+1][1], dp[n][0] - A[n], dp[n][1] + A[n]]);
    }
    console.log(dp[N][0]);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
	"sort"
)

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	ans := 0
	for i := 0; i < n-1; i += 2 {
		sum := a[i] + a[i+1]
		ans += abs(sum)
	}

	if n%2 == 1 {
		ans += a[n-1]
	}
	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	sum := 0
	min := 1000000000
	msum := 0
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		rv := abs(v)
		sum += rv
		if rv < min {
			min = rv
		}
		if v < 0 {
			msum++
		}
	}
	if msum%2 == 0 {
		fmt.Println(sum)
	} else {
		fmt.Println(sum - min*2)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
//  [go]
package main

import (
	"fmt"
	"math"
	"sort"
)

func abs(x int) int { return int(math.Abs(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) > abs(a[j]) }

func main() {
	var N, ans int
	fmt.Scan(&N)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	sort.Sort(SortBy(A))
	for i := 0; i < N-1; i++ {
		if A[i] < 0 {
			A[i] *= (-1)
			A[i+1] *= (-1)
		}
		ans += A[i]
	}
	fmt.Println(ans + A[N-1])
}
//  [ruby]
# https://atcoder.jp/contests/abc125/tasks/abc125_d
n = gets.to_i
$nums = gets.split.map(&:to_i)

DP = [Array.new(10**7, nil), Array.new(10**7, nil)]
DP[0][0] = 0
DP[1][0] = -1 * 10**9

1.upto(n) do |idx|
  num = $nums[idx - 1]
  [0, 1].each do |reversed|
    if reversed == 1
      DP[reversed][idx] = [ DP[0][idx - 1] - num, DP[1][idx - 1] + num ].max
    else
      DP[reversed][idx] = [ DP[0][idx - 1] + num, DP[1][idx - 1] - num ].max
    end
    # puts "DP[#{reversed}][#{idx}] = #{DP[reversed][idx]}"
  end
end

puts DP[0][n]
//  [ruby]
N = gets.to_i
A = gets.split.map(&:to_i)

INF = 10**9
dp0 = [-INF] * (N+1)
dp1 = [-INF] * (N+1)
dp0[0] = 0

N.times do |i|
  dp0[i+1] = [dp0[i+1], dp0[i] + A[i]].max
  dp0[i+1] = [dp0[i+1], dp1[i] - A[i]].max
  if i<N-1
    dp1[i+1] = [dp1[i+1], dp0[i] - A[i]].max
    dp1[i+1] = [dp1[i+1], dp1[i] + A[i]].max
  end
end
puts [dp0[N], dp1[N]].max
//  [ruby]
N = gets.to_i
a_list = gets.split.map(&:to_i)
MIN = -(10 << 60)
dp = Array.new(N + 10)
dp[0] = [0, MIN]
(0...N).each do |i|
  a = a_list[i]
  dp[i + 1] = Array.new(2)
  dp[i + 1][0] = [
    dp[i][0] + a,
    dp[i][1] + (-a)
  ].max
  dp[i + 1][1] = [
    dp[i][0] + (-a),
    dp[i][1] + a
  ].max
end
puts dp[N][0]
//  [rust]
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [i64;n]
    }

    let mut exist_zero = false;
    let mut min_abs = std::i64::MAX;
    let mut abs_total = 0;

    let mut minus_count = 0;
    for i in 0..n {
        if a[i] < 0 {
            minus_count += 1;
        } else if a[i] == 0 {
            exist_zero = true;
        }

        let abs = a[i].abs();
        min_abs = cmp::min(min_abs, abs);
        abs_total += abs;
    }

    //println!("{} {} {}", abs_total, min_abs, exist_zero);

    if exist_zero {
        println!("{}", abs_total);
    } else {
        if minus_count % 2 == 1 {
            println!("{}", abs_total - 2 * min_abs);
        } else {
            println!("{}", abs_total);
        }
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
//  [rust]
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();

    let mut b: Vec<i64> = vec![0; n];

    let mut cnt = 0;
    let mut ans = 0;
    for i in 0..n {
        b[i] = a[i].abs();
        ans += b[i];
        if a[i] < 0 {
            cnt += 1;
        }
    }
    b.sort();
    if cnt % 2 > 0 {
        ans -= b[0] * 2;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
//  [rust]
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a: Vec<i32> = (0..n).map(|_| input()).collect();
    a.sort_by_key(|&a| a.abs());

    let mut sum: i64 = a.iter().map(|&a| a.abs() as i64).sum();
    let neg: usize = a.iter().filter(|&&a| a < 0).count();
    if neg & 1 == 1 {
        sum -= 2 * a[0].abs() as i64;
    }
    println!("{}", sum);
}
//  [swift]
readLine()
let A=readLine()!.characters.split(" ").map{Int(String($0))!},a=A.map{abs($0)}
print(a.reduce(0){$0+$1}-A.filter{$0<0}.count%2*2*a.minElement()!)
//  [swift]
let N = Int(readLine()!)!
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
print(A.reduce(0){$0+abs($1)}-A.map{abs($0)}.minElement()!*(A.filter{$0<0}.count%2>0 ?2:0))
//  [typescript]
const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (as) => {
  let r = 0
  let fNeg = as.filter((a) => a < 0)
  let zeroNum = as.filter((a, i) => {
    return a == 0
  })
  let min = Math.min(...as.map((a) => Math.abs(a)))
  let sum = as.reduce((a, b) => Math.abs(a) + Math.abs(b), 0)
  if (fNeg.length % 2 == 0 || zeroNum > 0) {
    return sum
  } else {
    return sum - min * 2
  }
}
const main = (input) => {
  const [n, as] = input.split("\n")
  return solve(as.split(" ").map(Number))
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}

if (process.env.NODE_ENV === "test") {
  // module.exports = (input) => solve(input.trim())
  // main(``)
  // solve(1, [2, 3, 4])
}
//  [typescript]
{
  const main = (input: string): void | string | number => {
    const r = reader(input)
    const N = r.n()
    const a = r.ns()

    let minu = 0
    let hasZero = false

    let min = Infinity

    a.forEach(v => {
      if (v === 0) {
        hasZero = true
      }
      if (v < 0) {
        minu++
      }
      min = Math.min(min, Math.abs(v))
    })
    if (hasZero || minu % 2 == 0) {
      return a.map(Math.abs).reduce((a, b) => a + b, 0)
    } else {
      return a.map(Math.abs).reduce((a, b) => a + b, 0) - min * 2
    }
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const res = main(getInput())

  if (typeof res === 'number' || typeof res == 'string') console.log(res)
}
//  [typescript]
{
  const main = (input: string): void | string | number => {
    const r = reader(input)
    const N = r.n()
    const a = r.ns()

    const dp: number[][] = []

    dp[0] = []
    dp[0][0] = 0
    dp[0][1] = -Infinity
    for (let i = 1; i < N + 1; i++) {
      // console.log(dp[i - 1])
      dp[i] = []
      dp[i][0] = Math.max(dp[i - 1][0] + a[i - 1], dp[i - 1][1] - a[i - 1])
      dp[i][1] = Math.max(dp[i - 1][0] - a[i - 1], dp[i - 1][1] + a[i - 1])
    }
    // console.log(dp[N - 1])

    return dp[N][0]
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const res = main(getInput())

  if (typeof res === 'number' || typeof res == 'string') console.log(res)
}
//  [python]
s = str(input())
t = str(input())
s_t_len = len(s)
count = 0
for i in range(s_t_len):
  if s[i] != t[i]:
    s_replace = s.replace(s[i], t[i], 1)
    count += 1
  else:
    pass
print(count)
//  [python]
s = str(input(""))
t = str(input(""))
count = 0
for  i in range(len(t)):
    if t[i] != s[i]:
        s.replace(s[i],t[i],1)
        count += 1
print(count)
//  [python]
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = STR()
t = STR()
ans = len(s)
for i, j in zip(s, t):
    if i == j:
        ans -= 1
print(ans)
//  [java]
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		sc.close();
		int i=0;
		int ans = 0;
		while(!Arrays.equals(S, T)){
			if(T[i]!=S[i]){
				S[i]=T[i];
				ans++;
			}
			i++;
		}
		System.out.println(ans);
	}
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static int dp[][] = new int[(1 << 21) + 1][21];
	static int dist[][] = new int[21][21];

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s1[] = br.readLine().split("");
		String s2[] = br.readLine().split("");

		int ans = 0;
		for (int i = 0; i < s1.length; i++) {
			if (!s1[i].equals(s2[i])) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		String S = in.next();
		String T = in.next();
		int n = 0;
		
		String SArray[] = S.split("");
		String TArray[] = T.split("");
		
		for(int i = 0;i < SArray.length;i++) {
			if(!SArray[i].equals(TArray[i])) {
				n++;
			}
		}
		
		System.out.println(n);
	}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef long long ll;
typedef long double ld;

int  main()
{
	string s,t; cin >> s >> t;

	int cnt = 0;
	if (s != t)
	{
		rep(i, s.size())
		{
			if (s[i] != t[i])
			{
				s[i] = t[i];
				cnt++;
			}
			if (s == t)
			{
				cout << cnt << endl;
				return 0;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){   
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    for(int i=0; ; i++){
        if(s[i] != t[i]){
            s[i] = t[i];
            cnt++;
        }
        if(s == t){
            cout << cnt << endl;
            return 0;
        } 
    }
    
}
//  [cpp]
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    int length = s.length();
    int ans = 0;
    rep(i, length) {
        // 一致したら終わり
        if(s == t) {
            break;
        }

        if(s[i] != t[i]) {
            s[i] = t[i];
            ans++;
        }
    }

    cout << ans << endl;
}
//  [c]
#include<stdio.h>
#include<string.h>


int main(){
    int len=0,i,count=0;

    char a[500000],b[500000];

    scanf("%s",a);
    scanf("%s",b);
    len=strlen(a);

    for(i=0;i<len;i++){
        if(strncmp(a,b,i+1)==0){
            
        }else{
           
            count++;
            a[i]=b[i];
        }
    }
    printf("%d",count);

    


    return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>


int main(void){
    char s[200001];
    char t[200001];
    int count = 0;
    scanf("%s", s);
    scanf("%s", t);
    for (int i=0; i<strlen(s);i++){
        if (s[i] != t[i]){
            char* temp = s[i];
            s[i] = t[i];
            t[i] = temp;
            count ++;
        }
    }
    printf("%d\n", count);
}
//  [c]
int main(){
	char str[200010];
	char lett;
	int len = 0, count = 0;
	scanf("%c", &lett);
	while(lett != '\n'){
		len++;
		str[len] = lett;
		scanf("%c", &lett);
	}
	for(int i = 1; i <= len; i++){
		scanf("%c", &lett);
		if(lett != str[i])
			count++;
	}
	printf("%d", count);
	
	return 0;
}
//  [javascript]
"use strict";

const main = (input) => {
    const [s, t] = input.split('\n');
    const n = s.length;
    let ans = 0;
    for (let i = 0; i < n; i++){
        if (s[i] !== t[i]) ans++;
    }

    console.log(ans);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const main = async () => {
  'use strict'
  const input = require('fs').readFileSync('/dev/stdin', 'UTF-8').trim()
  
  let setting = input.split('\n')
  
  const str = setting[0].split('')
  const sample = setting[1].split('')

  let count = 0

  for (let i = 0; i < str.length; i++) {
    if (str[i] !== sample[i]) {
      count++
    }
  }

  console.log(count)
}

main()
//  [javascript]
let main = (input) => {
    let usrInput = input.split(/\n/)
    let time = 0
    if (usrInput[0] !== usrInput[1]) {
        for (let index = 0; index < usrInput[0].length; index++) {
            if (usrInput[0][index] != usrInput[1][index]) {
                time++
            }
        }
    }
    console.log(time)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [go]
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t string
	count := 0
	fmt.Scan(&s, &t)
	sSlice := strings.Split(s, "")
	tSlice := strings.Split(t, "")

	for index, ss := range sSlice {
		if ss != tSlice[index] {
			count++
		}
	}
	fmt.Println(count)
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var s, t string
	count := 0
	fmt.Scan(&s, &t)

	S := make([]string, len([]rune(s)))
	T := make([]string, len([]rune(t)))

	for pos, value := range s {
		S[pos] = string(value)
	}

	for pos, value := range t {
		T[pos] = string(value)
		if S[pos] != T[pos] {
			count++
		}
	}
	fmt.Println(count)
}
//  [ruby]
s = gets.chomp
t = gets.chomp

count = 0
i = 0
while true do
  if s == t
    puts count
    break
  elsif s[i] != t[i]
    s[i] = t[i]
    count += 1
    i += 1
  else
    i += 1
  end
end