jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int N = sc.nextInt();
    int K = sc.nextInt();

    int a[] = new int[N];
    for (int i = 0; i < K; i++) {
      int d = sc.nextInt();
      for (int j = 0; j < d; j++) {
        int A = sc.nextInt();
        a[A - 1] += 1;
      }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (a[i] == 0) {
        ans++;
      }
    }
    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}
//  [java]
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[]d = new int[n];
    int[]a = new int[k];
    int[]s = new int[n];
    		
    for(int i=0; i<k; i++) {
    	d[i] = sc.nextInt();
    		for(int j=0; j<d[i]; j++) {
    			 a[i] = sc.nextInt();
    			 	s[a[i]-1]++;
    		}
    }
    int cou = 0;
    for(int i=0; i<n; i++) {
    	if(s[i] == 0){
    		cou++;
    	}
    }
    		System.out.println(cou);
    		}
}
//  [java]
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        HashSet<Integer> hs = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int d = Integer.parseInt(sc.next());
            for (int j = 0; j < d; j++) {
                hs.add(Integer.parseInt(sc.next()));
            }
        }
        int answer = n - hs.size();
        System.out.println(answer);
        sc.close();
    }

}
//  [java]
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[]d = new int[k];
    int[]a = new int[k];
    int[]sunuke = new int[n];
    
    for(int i=0; i<k; i++){
        d[i] = sc.nextInt();
        	for(int j=0; j<d[i]; j++) {
        		a[j] = sc.nextInt();
        		sunuke[a[j]-1]++;
        	}
    }
    int cou = 0;
    for(int i=0; i<n; i++) {
    	if(sunuke[i] == 0){
    		cou++;
    	}
    }
    
    System.out.println(cou);
    }
}
//  [cpp]
#include <cstdio>

int n, k, a[105];

int read() {
    int x = 0, f = 1; char s;
    while((s = getchar()) < '0' || s > '9') if(s == '-') f = -1;
    while(s >= '0' && s <= '9') {x = (x << 1) + (x << 3) + (s ^ 48); s = getchar();}
    return x * f;
}

int main() {
    int x;
    n = read(), k = read();
    for(int i = 1; i <= k; ++ i) {
        x = read();
        for(int j = 1; j <= x; ++ j) a[read()] = 1;
    }
    x = 0;
    for(int i = 1; i <= n; ++ i)
        if(! a[i]) ++ x;
    printf("%d\n", x);
    return 0;
}
//  [cpp]
#include <cstdio>
#include <cstring>

inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch>'9' || ch<'0'){
		if(ch=='-')
		f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-48;
		ch=getchar();
	}
	return x*f;
}
int n,k,cnt;
bool vis[105];

int main(){
	memset(vis,true,sizeof(vis));
	n=read();k=read();
	for(int i=1;i<=k;++i){
		int d=read();
		for(int i=1;i<=d;++i)
		vis[read()]=false;
	}
	for(int i=1;i<=n;++i)
	if(vis[i])++cnt;
	printf("%d\n",cnt);
}
//  [cpp]
#include <cstdio>

int N,K;

bool has[102];

int main(){
    scanf("%d%d",&N,&K);

    for(int i=0;i<K;i++){
        int k;
        scanf("%d",&k);
        for(int i=0;i<k;i++){
            int d;
            scanf("%d",&d);
            has[d]=true;
        }
    }

    int ans=0;
    for(int i=1;i<=N;i++) if (!has[i]) ans++;

    printf("%d\n",ans);

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#include<vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k;
    cin >> n >> k;
    int N[n];
    for(int i=0; i<k; i++){
        int m;
        cin >> m;
        for(int j=0; j<m; j++){
            int a;
            cin >> a;
            N[a-1] = 1;
        }
    }

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

    cout << ans << endl;

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#include<vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k;
    cin >> n >> k;
    int N[n];
    for(int i=0; i<k; i++){
        int m;
        cin >> m;
        for(int j=0; j<m; j++){
            int a;
            cin >> a;
            N[a-1] =1;
        }
    }

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

    cout << ans << endl;

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#include<vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k;
    cin >> n >> k;
    int N[n];
    for(int i=0; i<k; i++){
        int m;
        cin >> m;
        for(int j=0; j<m; j++){
            int a;
            cin >> a;
            N[a-1] =1;
        }
    }

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

    cout << ans << endl;

    return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
  int n,k,p,d,a[101]={0},i,j,m=0;
  scanf("%d%d",&n,&k);
  for(i=0;i<k;i++){
    scanf("%d",&p);
    for(j=0;j<p;j++){
      scanf("%d",&d);
      a[d]=1;
    }
  }
  for(i=1;i<=n;i++){
    if(a[i]==0){
      m++;
    }
  }
  printf("%d\n",m);
  return 0;
}
//  [c]
#include <stdio.h>
 
int main(void){
   int N, K;

   scanf("%d %d",&N,&K);

   int d[K], A[K][N], i, j, B[N], ans=0;

   for(i=0;i<K;i=i+1){
      scanf("%d",&d[i]);

      for(j=0;j<d[i];j=j+1){
         scanf("%d",&A[i][j]);
      }
   }

   for(i=0;i<N;i=i+1)
      B[i]=0;
   
   for(i=0;i<K;i=i+1){
      for(j=0;j<d[i];j=j+1){
         B[(A[i][j]-1)]=B[(A[i][j]-1)]+1;
      }
   }  
   
   for(i=0;i<N;i=i+1){
      if(B[i]==0)
      ans=ans+1;
   }

   printf("%d\n",ans);
   
   return 0;
}
//  [c]
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

bool arr[101];

uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }

int main(void){
	uint32_t n=nextpint();
	uint32_t k=nextpint();
	for(uint32_t i=k; i>0; i--){
		uint32_t d=nextpint();;
		for(uint32_t j=d; j>0; j--){
			uint32_t a=nextpint();
			arr[a]=true;
		}
	}
	uint32_t ans=0;
	for(uint32_t i=n; i>0; i--){
		if(!arr[i]) ans++;
	}
	printf("%"PRIu32"\n", ans);
}
//  [c]
#include<stdio.h>

int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  int p[101]={},d[k];
  for(int i=0;i<k;i++){
    scanf("%d",&d[i]);
      for(int j=0;j<d[i];j++){
        int pn=0;
        scanf("%d",&pn);
        p[pn]++;
      }
  }
  
  int c=0;
  for(int i=0;i<n;i++){
    if(p[i]==0){
      c++;
    }
  }
  
  printf("%d\n",c);
  return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  int p[101]={},d[k];
  for(int i=0;i<k;i++){
    scanf("%d",&d[i]);
      for(int i=0;i<d;i++){
        int pn=0;
        scanf("%d",&pn);
        p[pn]++;
      }
  }
  
  int c=0;
  for(int i=0;i<n;i++){
    if(p[i]==0){
      c++;
    }
  }
  
  printf("%d\n",c);
  return 0;
}
//  [c]
#include<stdio.h>

int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  int p[n]={},d[k];
  for(int i=0;i<k;i++){
    scanf("%d",&d[i])
      for(int i=0;i<d;i++){
        int pn=0;
        scanf("%d",&pn);
        p[pn]++;
      }
  }
  
  int c=0;
  for(int i=0;i<n;i++){
    if(p[i]==0){
      c++;
    }
  }
  
  printf("%d\n",c);
  return 0;
}
//  [javascript]
function main(input){

    inputArray=input.split('\n');
    NK=inputArray[0].split(' ');
    N = parseInt(NK[0]);
    K = parseInt(NK[1]);
    out=0;
    sunukeArray=new Array(N-1);//all sunuke
    for(i=0;i<N;i++){
        sunukeArray[i]='0';
    }
    
    for(i=1;i<=2*K;i=i+2){
        kashiSnk=inputArray[i+1].split(' ');//sunuke have kashi
        for(j=0;j<parseInt(inputArray[i]);j++){
            sunukeArray[parseInt(kashiSnk[j])-1]='1';
        }
        kashiSnk.length=0;
    }

    for(i=0;i<N;i++){
        if(sunukeArray[i]=='0'){
            out++;
        }
    }
    console.log(out);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const Main = (input) => {
    const lines = input.split('\n')
    line0=lines[0].trim().split(" ")
    N=parseInt(line0[0])
    K=lines[1]
    a=new Array(N)
    for (i=2;i<lines.length;i=i+2){
        line=lines[i].trim().split(" ").map(n=>parseInt(n))
        for(j=0;j<line.length;j++){
            a[line[j]-1]=-2
        }
    }
    ans=0
    for( i=0 ;i<a.length;i++){
        if(a[i]!==-2){
            ans=ans+1
        }
    }
    console.log(ans)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
const Main = (input) => {
  const tmp = input.trim().split('\n')
  const N = parseInt(tmp[0].split(' ')[0])
  const K = parseInt(tmp[0].split(' ')[1])

  const sunuke = {}

  for (let i = 1; i <= N; ++i) {
    sunuke[i] = ''
  }

  for (let j = 1; j <= K; j++) {
    const sweets = (j * 2 - 1).toString()
    const sunukeNum = tmp[j * 2].split(' ').map(n => n.toString())
    sunukeNum.forEach(elem => {
      sunuke[elem] += sweets
    })
  }

  let result = 0

  for (let i = 1; i <= N; ++i) {
    if (sunuke[i].length === 0) {
      result += 1
    }
  }

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function Main(input) {
  input=input.split("\n");
  
  const N=input[0].split(' ')[0]-0;
  const K=input[0].split(' ')[1]-0;
  var temp;
  var array=new Array(N+1);
  array.fill(false);
  for(var i=1;i<=K*2;i+=2){
    temp=input[i].split(' ').map(e=>{return e});
    temp.forEach(e=>{array[e]=true;});
  }
  var ans=0;
  array.forEach(e=>{
    if(!e){ans++;}
  });
  console.log(ans-1);
  
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input){
    input=input.split("\n");  //ここまで必須
    var gyo=input.length;
    inputA=input[0].split(" ");
    var retu=new Array(inputA[0]);
    for (i=1;i<gyo;i=i+2){
        var inputB=input[i+1].split(" ");
        for (j=0;j<inputB.length;j++){
            retu[inputB[j]-1]=1
        }
    }
    var count=0;
    for (k=0;k<inputA[0];k++){
        if (retu[k]!=1){
            count++
        }
    }
    console.log(count);}

Main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [javascript]
function main(arg) {
  // var str = arg.trim();
  const array = arg.trim().split("\n");
  const first = array[0].split(" ");
  // const first = array[0].split(" ");
  const N = parseInt(first[0]);
  const K = parseInt(first[1]);
  let rsultArray = new Array(N);

  let counter = 0;
  for (let i = 0; i < K; i++) {
    let okashi = parseInt(array[counter + 1].trim().split("\n"));
    let person = array[counter + 2].trim().split("\n");
    for (let j = 0; j < person.length; j++) {
      rsultArray.splice(person[j] - 1, person[j] - 1, "1"); // 二番目に挿入
    }
    // console.log(okashi);
    // console.log(person);
    counter += 2;
  }

  let answer = 0;
  for (let k = 0; k < rsultArray.length; k++) {
    if (!rsultArray[k]) {
      answer++;
    }
  }
  console.log(answer);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main("3 2\n2\n1 3\n1\n3");
// main("3 3\n1\n3\n1\n3\n1\n3");
//https:/ / atcoder.jp / contests / abc166 / tasks / abc166_a;
//  [go]
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()
	k := readInt()

	okasi := make([]int, n)

	for i := 0; i < k; i++ {
		d := readInt()
		for j := 0; j < d; j++ {
			a := readInt()
			okasi[a-1] = 1
		}
	}
	sum := 0
	for _, i := range okasi {
		sum += i
	}

	fmt.Fprintln(w, n-sum)
}
//  [go]
package main

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

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, k := scanInt(), scanInt()
	a := map[int]int{}
	for i := 0; i < k; i++ {
		d := scanInt()
		for j := 0; j < d; j++ {
			p := scanInt()
			a[p] = 1
		}
	}
	fmt.Println(n - len(a))
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func main() {
	sc.Split(bufio.ScanWords)
	var allSunukeCount, okahiCount = nextInt(), nextInt()
	var okashiSunukes []int
	for i := 0; i < okahiCount; i++ {
		sunukeCount := nextInt()
		for i := 0; i < sunukeCount; i++ {
			sunukeNum := nextInt()
			if !contains(okashiSunukes, sunukeNum) {
				okashiSunukes = append(okashiSunukes, sunukeNum)
			}
		}
	}
	fmt.Println(allSunukeCount - len(okashiSunukes))
}
//  [go]
package main

import "fmt"

func main() {
  var n, k int
  fmt.Scanf("%d %d", &n, &k)
  
  a := make([]int, n)
  
  for i:=0; i<k; i++ {
    var d int
    fmt.Scan(&d)
    for j:=0; j<d; j++ {
      var s int
      fmt.Scan(&s)
      a[s-1]+=1
    }
  }
  
  var r int
  for i:=0; i<k; i++ {
    if a[i] == 0 {
      r+=1
    }
  }
  
  fmt.Println(r)
}
//  [go]
package main

import "fmt"


func main() {
	var n, k, d, tmp int
  	fmt.Scan(&n, &k)
  	a := map[int]int{}
  
    for i := 0; i < k; i++ {
      fmt.Scan(&d)

      for j := 0; j < d; i++ {
        fmt.Scan(&tmp)
        _, err := a[tmp]
        if err {
        	a[tmp]++
        }else {
        	a[tmp] = 0
        }
      } 
    }
  fmt.Println(n - len(a))
}
//  [go]
package main

import "fmt"


func main() {
	var n, k, d, tmp int
  	fmt.Scan(&n, &k)
  
    for i := 0; i < k; i++ {
      fmt.Scan(&d)
      a := map[int]int{}

      for j := 0; j < d; i++ {
        fmt.Scan(&tmp)
        _, err := a[tmp]
        if err {
        	a[tmp]++
        }else {
        	a[tmp] = 0
        }
      } 
    }
  fmt.Println(n - len(a))
}
//  [ruby]
n, k = gets.split.map(&:to_i)
h = Hash.new(0)
d = []
a = []
k.times do
  d = gets.to_i
  gets.split.map(&:to_i).each { |i| h[i] += 1 }
end

puts n - h.size
//  [ruby]
N, K = gets.split.map(&:to_i)
A = []
K.times {
  d = gets.to_i
  A << gets.split.map(&:to_i)
}
a = (1..N).to_a
A = A.flatten
ans = a - A
puts ans.count
//  [ruby]
n, k = readline.split(' ').map(&:to_i)

a = Array.new(k)

a.map! do
  readline
  readline.split(' ').map(&:to_i)
end

p n - a.flatten.uniq.size
//  [ruby]
n,k=gets.split.map &:to_i
ans=[]
k.times{|i|
gets
ans << (gets.split.map &:to_i)
}
puts n-ans.uniq.size
//  [ruby]
N,K = gets.split.map(&:to_i)
has = Array.new(N, false)
 
K.times {
  gets
  a = gets.split.map(&:to_i)
  a.each { |_a|
    has[_a-1] = true
  }
}
 
cnt = 0
#p has
has.each { |v|
  if v == false
    cnt = 1
  end
}
 
puts cnt
//  [ruby]
nk = gets.chomp

nkarr = nk.split(" ")

n = nkarr[0].to_i
k = nkarr[1].to_i

d = []
d_n = []
count = 0
while count < k do
    temp_k = gets.chomp.to_i
    temp_n = gets.chomp
    temp_n = temp_n.split(" ")
    temp_n = temp_n.map { |n|
        n.to_i
    }    
    d << temp_k
    d_n << temp_n
    count += 1
end

dn_uniq = d_n.flatten!.uniq
p(dn_uniq)

ans = 0
for i in 1..n do
    if dn_uniq.include? i
       ans += 1
    end
end

if ans == 0
    puts(0)
    exit
end

ans = n - ans 
puts(ans)
//  [rust]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        K: usize,
    }

    let mut cnt = vec![0; N];

    for _ in 0..K {
        input! {
            D: usize,
            A: [Usize1; D],
        }
        for &a in &A {
            cnt[a] += 1;
        }
    }

    println!("{}", cnt.iter().filter(|&&c| c == 0).count());
}
//  [rust]
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
 
#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut a = vec![];
    for _ in 1..=k {
        input! {
            d: usize,
            mut ad: [usize; d],
        }
        a.append(&mut ad);
    }
    a.sort();
    a.dedup();
    println!("{}", n - a.len());
}
//  [rust]
use itertools::Itertools as _;
use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize,
        ass: [[Usize1]],
    }

    let ans = n - ass.into_iter().flatten().unique().count();
    println!("{}", ans);
}
//  [rust]
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        a: [[usize]; k],
    }
    // annotate for rust-analyzer
    let (n, k) = (n as usize, k as usize);
    let a: Vec<Vec<usize>> = a;

    let mut map = HashMap::<usize, usize>::new();
    for i in 0..k {
        for di in 0..a[i].len() {
            *map.entry(di).or_insert(0) += 1;
        }
    }

    println!("{}", n - map.len());
}
//  [rust]
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u16,
        k: u16,
    }

    let mut sunuke = vec![0; n as usize];
    for i in 0..k {
        input! {
            dd: u16,
            aa: [u16; dd as usize],
        }
        for j in 0..dd {
            sunuke[j as usize] += 1;
        }
    }
    println!("{}", sunuke.into_iter().filter(|&s| s == 0).count());
}
//  [rust]
use proconio::input;
use proconio::marker::Chars;
use std::collections::HashMap;
use std::vec::Vec;

fn main() {
	input! {
		n: usize,
		k: usize,
	}
	//   お菓子図鑑
	let mut map: HashMap<usize, usize> = HashMap::new();
	for i in 0..n {
		let _ = map.entry(i).or_insert(0);
	}

	// すぬけくんのポケットにあるお菓子を調べる
	for _ in 0..k {
		input! {
			d: usize,
			v: [usize; d],
		}
		// ポケットをチェック
		for a in v.iter() {
			let entry = map.entry(a - 1).or_insert(0);
			*entry += 1;
		}
	}

	// お菓子を持っていいないカウント
	let mut ans = 0;
	for (_, &v) in map.iter() {
		if v == 0 {
			ans += 1;
		}
		3 3
		1
		3
		1
		3
		1
		3}

	println!("{}", ans);
}
//  [swift]
let inp = readLine()!.split(separator: " ").map { Int($0)! }
let (N, K) = (inp[0], inp[1])
let As = (1...K).map { _ -> [Int] in
    _ = readLine()
    return readLine()!.split(separator: " ").map { Int($0)! }
}

print(N - Set(As.flatMap{$0}).count)
//  [swift]
let nl = readLine()!.split(separator: " ").map { Int($0)! }
let n = nl[0], k = nl[1]
var a = [[Int]](repeating: [Int](), count: n)
for di in 1..<k+1 {
  _ = readLine()
  let nr = readLine()!.split(separator: " ").map { Int($0)! }
  for i in nr {
    a[i-1] = a[i-1] + [di]
  }
}
print(a.filter { $0.isEmpty }.count)
//  [swift]
func main() {
    let inputs = readLine()!.split(separator: " ")
    let N = Int(inputs[0])!
    let K = Int(inputs[1])!
    var nums = Array(repeating: 0, count: N)
    for _ in 0..<K {
        let _ = readLine()!
        let A = readLine()!.split(separator: " ").map { Int($0)! }
        for a in A {
            nums[a - 1] += 1
        }
    }
    let output = nums.filter { $0 == 0 }.count
    print(output)
}

main()
//  [swift]
let NK = readLine()!.components(separatedBy: " ")
let N = Int(NK[0])!
let K = Int(NK[1])!

var result: [Bool] = [Bool](repeating: false, count: N)
var d = readLine()

while d != nil {
   let line = readLine()!.components(separatedBy: " ").map{ Int($0)! }
   for peopleNum in line {
      result[peopleNum - 1] = true
   }
   d = readLine()
}

print(result.filter{ $0 == false}.count)
//  [swift]
import Foundation

let nk = readLine()!.split(separator:" ").map{Int($0)!}
var sets: Set<Int> = []
for _ in 1...nk[1] - 1{
  let _ = readLine()!
  let A = readLine()!.split(separator:" ").map{Int($0)!}
  for i in A{
  sets.insert(i)
  }
}
print(nk[0] - sets.count)
//  [swift]
import Foundation

let nk = readLine()!.split(separator:" ").map{Int($0)!}
var sets: Set<Int> = []
for _ in 1...nk[1] - 1{
  let c = readLine()!
  let A = readLine()!.split(separator:" ").map{Int($0)!}
  for i in A{
  sets.insert(i)
  }
}
print(nk[0] - sets.count)
//  [typescript]
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const [n, k] = args[0].map(x => parseInt(x));
const snuke: boolean[] = Array(n).fill(false);
for (let i = 0; i < k; i++) {
    const d = parseInt(args[2 * i + 1][0]);
    for (let j = 0; j < d; j++) {
        snuke[parseInt(args[2 * i + 2][j]) - 1] = true;
    }
}

const cnt = snuke.filter(x => x === false).length;

console.log(cnt);
//  [typescript]
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const [n, k]: number[] = this.args[0].map(Number);
            const set = new Set();

            for (let i = 2; i < k * 2+1; i = i + 2) {
                const val: number[] = this.args[i].map(Number);
                val.forEach(x => {
                    set.add(x)
                })
            }
            console.log(n - set.size);
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}
//  [typescript]
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const [n, k] = inputs[0].split(' ').map(Number);
  let list = new Array(n).fill(0);

  for (let i = 1; i <= k; i++) {
    let treatList = inputs[2 * i].split(' ').map(Number);
    for (let j = 0; j < treatList.length; j++) {
      if (list[treatList[j] - 1] === 0) {
        list[treatList[j] - 1] = 1;
      }
    }
  }

  console.log(list.filter((num) => num === 0).length);
}
//  [typescript]
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')
const output = (x: any) => console.log(x)
// debug(input)
const [N, K] = input[0].split(' ').map(n => parseInt(n, 10))

const set = new Set()
for (let i = 0; i < K*2; ++i) {
    if (i % 2 !== 0 || i === 0) continue
    const m = input[i].split(' ').map(n => parseInt(n, 10))
    for (let j = 0; j < m.length; ++j) {
        set.add(m[j])
    }
}
// debug(set)
output(N - set.size)
//  [typescript]
import * as fs from 'fs'

export function TrickOrTreat(input: number[], excludes: number[][]):number {
    excludes.forEach(exclude => {
        // inputがexcludeに存在しなければ残す
        input = input.filter(num => exclude.indexOf(num) === -1)
        if(input.length === 0) {
            return 0
        }
    })
    return input.length
}

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')

const firstLine = input[0].split(' ').map(c => parseInt(c))
const peopleNum = firstLine[0]
const peopleArray = [...Array(peopleNum).keys()].map(num => num + 1)
const treatTypeNum = firstLine[1]
const excludes: number[][] = []
// 2 4 6 ...
for(let i = 0;i<treatTypeNum-1;i++) {
    const array = input[i+2].split(' ').map(c => parseInt(c))
    excludes.push(array)
}

console.log(TrickOrTreat(peopleArray, excludes))
//  [typescript]
function Main(input) {
    const _input = input.split("\n")
    const NK = input[0].split(" ")
    const N = NK[0]
    // const K = NK[1]
    
    let ans = new Array(Number(N)).fill(0)
    for (let k = 2; k < _input.length; k += 2) {
        const hito = _input[k].split(" ");
        hito.forEach(h => {
            ans[Number(h)-1]++
        })
    }
    console.log(ans.filter(e => e === 0).length)

}
// Main()
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [python]
def main():
    s = open(0).read()
    b = s.count('-')
    _, *c, = map(int, s.replace('-', '').split())
    z = c.count(0)
    d = min(c)
    e = sum(c)

    if b % 2 == 0 or z > 0:
        print(e)
    else:
        print(e - 2 * d)


if __name__ == '__main__':
    main()
//  [python]
def main():
    s = open(0).read()
    b = s.count('-')
    z = s.count(' 0 ')
    _, *c, = map(int, s.replace('-', '').split())

    d = min(c)
    e = sum(c)

    if b % 2 == 0 or z > 0:
        print(e)
    else:
        print(e - 2 * d)


if __name__ == '__main__':
    main()
//  [python]
def main():
    N = int(input())
    A = list(map(int, input().split()))
 
    B = list(map(abs, A))
    C = [a for a in A if a < 0]
    if len(C) % 2 == 0:
        print(sum(B))
    else:
        print(sum(B) - min(B)*2)
    
if __name__ == "__main__":
    main()
//  [python]
N=int(input())
A=list(map(int,input().split()))

plus=0
zero=0
minus=0

for i in range(N):
    if A[i]>0:
        plus+=1
    elif A[i]<0:
        minus+=1
    else:
        zero+=1
ans=0
m=10*9+10
for i in range(N):
    ans+=abs(A[i])
    m=min(m,abs(A[i]))


if minus%2==0 or zero>0:
    pass
else:
    ans=ans-2*m

print(ans)
//  [python]
N = int(input())
A = list(map(int, input().split()))

souwa = 0
cnt = 0
keep = 1e9

for i in range(N):
    if A[i] < 0:
        cnt += 1
        A[i] *= (-1)

    souwa += A[i]
    keep = min(keep, A[i])

print(souwa - 2 * keep * (cnt % 2))
//  [python]
import numpy as np

n=int(input())
A=np.array(list(map(int,input().split())))
A = np.abs(A)

if 0 in A:
  print(np.sum(A))
else:
  print(np.sum(A) - np.min(A))
//  [java]
import java.util.*;
import java.io.*;

public class Main {
    static long INF = 1000000000;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        long[] a = new long[n];
        long min = INF;
        long cntMinus = 0;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            if (a[i] < 0) {
                cntMinus++;
            }
            ans += Math.abs(a[i]);
            min = Math.min(min, Math.abs(a[i]));
        }
        if (cntMinus % 2 == 0) {
            System.out.println(ans);
            return;
        }
        System.out.println(ans - Math.abs(min) * 2);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
//  [java]
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		long ans = 0L;
		long min = 100000000000L;
		int count = 0;

		for (int i = 0; i < N; i++) {
			long X = sc.nextLong();
			if (X < 0) {
				count++;
			}
			min = Math.min(min, X);
			ans += Math.abs(X);
		}
		if (count % 2 == 0) {
			System.out.println(ans);
		} else {
			System.out.println(ans-2*min);
		}
		
		sc.close();
	}
};
//  [java]
import java.util.Arrays;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int cnt = 0;
    long [] A = new long[N];
    long sum = 0;
    for(int i = 0; i < N; i++) {
    	A[i] = sc.nextLong();
    	if(A[i] < 0) cnt++;
    	sum += Math.abs(A[i]);
    }
    long ans = 0;
    if(cnt % 2 == 0) ans = sum;
    else {
    	Arrays.sort(A);
    	sum -= A[0];
    	ans = sum;
    }
    System.out.println(ans);
  }
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class ABC125_d {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			int minus = 0;
			int min = Integer.MAX_VALUE;
			long sum = 0;
			for (int i = 0; i < n; ++i) {
				int val = (int) sc.scanLong();
				if (val < 0)
					++minus;
				sum += Math.abs(val);
				min = Math.min(min, Math.abs(val));
			}
			if (minus % 2 == 0)
				System.out.println(sum);
			else
				System.out.println(sum - (min<<1));
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


const int cm = 1 << 17;
char cn[cm], * ci = cn, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

int main() {
	fread(cn, 1, cm, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	int fu = 0;
	int saishou = 1e9;
	ll goukei = 0;
	rep(i, N) {
		if (ci - cn + 16 > cm) {
			if ((ct = getcha()) == '-') { fu ^= 1; ct = getcha(); }
			int A = ct - '0';
			while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
			goukei += A;
			chmin(saishou, A);
		}
		else {
			if ((ct = *ci++) == '-') { fu ^= 1; ct = *ci++; }
			int A = ct - '0';
			while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
			goukei += A;
			chmin(saishou, A);
		}
	}

	if (fu) goukei -= saishou * 2;

	printf("%lld", goukei);

	Would you please return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

int main() {
	fread(cn, 1, cm, stdin); 
	ci = cn;
	int N = 0;
	int fu = 0;
	int saishou = 1e9;
	ll goukei = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	rep(i, N) {
		if (ci - cn + 16 > cm) {
			ct = getcha();
			if (ct == '-') { fu ^= 1; ct = getcha(); }
			int A = ct - '0';
			while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
			goukei += A;
			saishou = min(saishou, A);
		}
		else {
			ct = *ci++;
			if (ct == '-') { fu ^= 1; ct = *ci++; }
			int A = ct - '0';
			while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
			goukei += A;
			saishou = min(saishou, A);
		}
	}

	if (fu & 1) goukei -= saishou * 2;

	co(goukei);

	Would you please return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int fu = 0;
int saishou = 1e9;
ll goukei = 0;

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline void getA() {
	char C = getcha();
	int pn = 1;
	if (C == '-') { fu ^= 1; C = getcha(); }
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	goukei += A;
	saishou = min(saishou, A);
}

int main() {
	fread(cn, 1, cm, stdin); 
	ci = cn;
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	rep(i, N) getA();

	if (fu & 1) goukei -= saishou * 2;

	co(goukei);

	Would you please return 0;
}
//  [cpp]
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto&& c : a) {
    cin >> c;
    c = abs(c);
  }

  /*   for (int i = 0; i < n - 1; i++) {
      if (a[i] >= 0 && a[i + 1] >= 0) {
        continue;
      } else if (a[i] < 0 && a[i + 1] < 0) {
        a[i] *= -1;
        a[i + 1] *= -1;
      } else {
        if (a[i] < 0) {
          if (abs(a[i]) > abs(a[i + 1])) {
            a[i] *= -1;
            a[i + 1] *= -1;
          }
        } else {
          if (abs(a[i]) < abs(a[i + 1])) {
            a[i] *= -1;
            a[i + 1] *= -1;
          }
        }
      }
    } */

  cout << accumulate(a.begin(), a.end(), 0LL) << endl;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    rep(i, N) cin >> A[i];
    for(int i = 0; i < N - 1; i++) {

        // A[i]*A[i+1]>0
        if(A[i] < 0 and A[i + 1] < 0) {
            A[i] *= -1;
            A[i + 1] *= -1;
        } else if(A[i] > 0 and A[i + 1] > 0) {

        }
        // A[i]*A[i+1]==0
        else if(A[i] * A[i + 1] == 0) {
            A[i] = abs(A[i]);
            A[i + 1] = abs(A[i + 1]);
        }
        // A[i]*A[i+1]<0
        else if(i == N - 2) {
            if(A[i] > A[i + 1] and abs(A[i]) < abs(A[i + 1])) {
                A[i] *= -1;
                A[i + 1] *= -1;
            } else if(A[i] < A[i + 1] and abs(A[i]) > abs(A[i + 1])) {
                A[i] *= -1;
                A[i + 1] *= -1;
            }
        } else {
            if(A[i] < 0) {
                A[i] *= -1;
                A[i + 1] *= -1;
            }
        }

        if(i == N - 2) {
            sum = sum + A[i] + A[i + 1];
        } else {
            sum += A[i];
        }
    }

    cout << sum << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int MAX = 1234567;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int X, Y;
    cin >> X >> Y;
    int s, t;

    if((2 * Y - X) < 0 or (2 * X - Y) < 0 or (2 * Y - X) % 3 != 0 or
       (2 * X - Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    } else {
        s = (2 * Y - X) / 3;
        t = (2 * X - Y) / 3;
    }
    // 前処理
    COMinit();
    // 計算
    cout << COM(s + t, s) % MOD << endl;
    return 0;
}
//  [c]
// AtCoder ABC125: D - Flipping Signs
// 2019.9.9 bal4u

#include <stdio.h>

typedef long long ll;

#if 1
int getchar_unlocked(void);
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF 0x7fffffff

int main()
{
	int i, minus, mi, A, N; ll ans;
	
	N = in(); 
	minus = 0, ans = 0, mi = INF;
	for (i = 0; i < N; i++) {
		A = in();
		if (A < 0) minus++, A = -A;
		if (A < mi) mi = A;
		ans += A;
	}
	if (minus & 1) ans -= 2*mi;
	printf("%lld\n", ans);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int N,i;
  long a[100005],sum,count,zero,min;
  char str[2000005],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a[0]=atol(p);
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
    a[i]=atol(p);
  }
  
  for(i=0,count=0,zero=0;i<N;i++){
    if(a[i]<0){
      count++;
    }
    if(a[i]==0){
      zero++;
    }
  }
  for(i=0;i<N;i++){
      sum+=labs(a[i]);
    }
  
  if(zero!=0 || count%2==0){
    printf("%ld\n",sum);
    return 0;
  }
  
  if(count%2==1){
    for(i=0,min=labs(a[0]);i<N;i++){
      if(labs(a[i])<min){
        min=labs(a[i]);
      }
    }
    printf("%ld\n",sum-2*labs(min));
    return 0;
    
  }

  
}
//  [c]
typedef long unsigned int size_t;
extern int printf (const char *__restrict __format, ...);
extern int scanf (const char *__restrict __format, ...) ;
extern int getchar (void);
extern int putchar (int __c);
int nextInt(){int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
char nextChar(){char f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
short nextShort(){short f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
long nextLong(){long f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
void println(){putchar(10);}
void print(char *f){while(*f){putchar(*f);f++;}}
void printInt(int f){if(f==0x80000000){print("-2147483648");return;}char c[11];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
void printLong(long f){if(f==0x8000000000000000){print("-9223372036854775808");return;}char c[20];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
int min2(int a, int b){return a>b?b:a;}
int n, g, i;
int a, min;
long sum;
int main(void){
 n=nextInt();
 min=0x0FFFFFFF;
 for(i=0; i<n; i++){
  a=nextInt();
  if(a<0){
   sum -= a;
   g++;
   min = min2(min, -a);
  }else{
   sum += a;
   min = min2(min, a);
  }
 }
 if(g&1){
  printLong(sum-2*min);
 }else{
  printLong(sum);
 }
 println();
}
//  [c]
#include <stdio.h>
#include <stdbool.h>
long long arr[100010];

int main()
{
	int n;
	scanf("%d", &n);
	bool odd = false;
	bool zero = false;
	int max = 0;
	int min = 0;
	long long res = 0;
	for(int i=1; i<n+1; ++i)
	{
		scanf("%lld", arr + i);	
		if(arr[i] == 0)
		{
			zero = true;
		}
		else if(arr[i] < 0)
		{
			odd = !odd;
			if(max == 0 || arr[max] < arr[i])
				max = i;
		}
		else if(arr[i] > 0)
		{
			if(min == 0 || arr[min] > arr[i])
				min = i;
		}
		res += arr[i] < 0 ? -arr[i] : arr[i];	
	}
	if(!zero && odd)
	{
		if(max > 0 && min > 0)
		{
			if( -arr[max] > arr[min])
			{
				arr[max] = -arr[max];
				res -= arr[min] + arr[max];
				arr[min] = -arr[min];
				res += arr[min] + arr[max] ;
			}
		}
		else if(min < 1)
		{
			arr[max] = -arr[max];
			res -= arr[max] + arr[max];
		}
	}
	
	printf("%lld\n", res);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdbool.h>
long long arr[100010];

int main()
{
	int n;
	scanf("%d", &n);
	bool odd = false;
	bool zero = false;
	int max1 = -1;
	int max2 = -1;
	int min1 = -1;
	int min2 = -1;
	long long res = 0;
	for(int i=0; i<n; ++i)
	{
		scanf("%lld", arr + i);	
		if(arr[i] == 0)
			zero = true;
		if(arr[i] < 0)
		{
			odd = !odd;
			if(max1 < 0)
				max1 = i;
			else
			{
				if(arr[max1] < arr[i])
				{	
					max2 = max1;
					max1 = i;
				}
			}
		}
		if(arr[i] > 0)
		{
			if(min1 < 0)
				min1 = i;
			else
			{
				if(arr[min1] > arr[i])
				{	
					min2= min1;
					min1 = i;
				}
			}
		}
		res += arr[i] < 0 ? -arr[i] : arr[i];	
	}
	if(!zero && odd)
	{
		if(max1 >= 0 && min1 >= 0)
		{
			if( -arr[max1] > arr[min1])
			{
				arr[max1] = -arr[max1];
				res -= arr[min1] + arr[max1];
				arr[min1] = -arr[min1];
				res += arr[min1] + arr[max1] ;
			}
		}
		else if(min1 < 0)
		{
			arr[max1] = -arr[max1];
			res -= arr[max1] + arr[max1];
		}
	}
	
	printf("%lld\n", res);
	return 0;
}
//  [c]
#include <stdio.h>
long long arr[100010];

int main()
{
	int n;
	scanf("%d", &n);
	int flag = 0;
	int nozero = 1;
	int max = 0;
	int min = 0;
	for(int i=1; i<n+1; ++i)
	{
		scanf("%lld", arr + i);	
		if(arr[i] < 0)
		{
			flag = !flag;	
			if(max == 0)
				max = i;
			if(arr[max] < arr[i])
				max = i;		
		}
		else
		{
			if(min == 0)
				min = i;
			if(arr[min] > arr[i])
				min = i;		
		} 

		if(arr[i] == 0)
			nozero = 0;	 		
	}
	if(flag && nozero)
	{
		if(-arr[max] > arr[min])
		{
			arr[max] = -arr[max];
			arr[min] = -arr[min];
		}
	}

	long long res = 0;
	for(int i=1; i<n+1; ++i)
	{
		if(i != min && i != max && arr[i] < 0)
			arr[i] = -arr[i];
		if(nozero == 0 && arr[i] < 0)
			arr[i] = -arr[i];
						
 		res += arr[i];
		
	}
	
	printf("%lld\n", res);
	return 0;
}