jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
// SPDX-License-Identifier: X11
// 2020-08-31
// Red Scarf (500pt)

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

#define ul32 uint_least32_t

int main() {
  ul32 N;
  scanf("%u\n", &N);
  ul32 *A = (ul32 *) calloc(N, sizeof(ul32));
  for (ul32 i = 0; i < N; i++)
    scanf("%u", &A[i]);

  ul32 *out = (ul32 *) calloc(N, sizeof(ul32));

  ul32 curr, i, j;
  for (i = 0, j = 0; i < N; i++) {
    if (!i) {
      curr = A[1];
      j = 2;
    }
    else if (i == 1) {
      curr = A[0];
      j = 2;
    }
    else {
      curr = A[0];
      j = 1;
    }
    for (; j < N; j++) {
      if (j == i)
        continue;
      curr ^= A[j];
    }

    out[i] = curr;
  }

  for (i = 0; i < N - 1; i++)
    printf("%u ", out[i]);
  printf("%u\n", out[N - 1]);

  free(A);
  free(out);
}
//  [c]
/*
 * FileName:     C
 * CreatedDate:  2020-06-21 20:42:28 +0900
 * LastModified: 2020-08-18 13:35:46 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int n;scanf("%d", &n);
    int *a = malloc(n*sizeof(int));
    int *ans = malloc(n*sizeof(int));
    memset(ans, 0, sizeof(ans));
    for(int i=0; i<n; i++)scanf("%d", a+i);
    for(int i=0; i<n; i++){
        int x_i = 0;
        for(int j=0; j<n; j++){
            if(i==j){
                continue;
            }
            x_i ^= a[j];
        }
        ans[i] = x_i;
    }
    for(int i=0; i<n; i++){
        printf("%d ", ans[i]);
    }
    printf("\n");
    free(a);
    return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
	int n;
	long long int a[30000];
	long long int all = 0;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		all ^= a[i];
	}

	for (i = 0; i < n; i++)
	{
		printf("%lld ", all ^ a[i]);
	}
	putchar('\n');

	return 0;
}
//  [javascript]
const [n, aStr] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
let as = aStr.split(/\s/).map(Number)
let total = as.reduce((a, b) => a ^ b)
console.log(as.map(n => n ^ total).join(' '))
//  [javascript]
const fs = require('fs')
const inputs = fs.readFileSync('/dev/stdin', 'utf8').trim().split(/\s+/).map(s => parseInt(s))

const n = inputs.shift()
const arr = inputs.slice()
const allXor = arr.reduce((a, b) => a ^ b, 0)
const results = arr.map(a => allXor ^ a)

console.log(results.join(' '))
//  [javascript]
console.log(function(args){
  const [[N],a] = args.trim().split('\n').map( r=>r.split(' ').map( v=>v|0 ) );
  let A = a[0];
  for ( let i = 1; i < N; i++ ) {
    A ^= a[i];
  }
  return a.map(v=>v^A).join(' ');
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [javascript]
function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    const [ n ] = readMany(1).map(it => parseInt(it))
    const a = readMany(n).map(it => parseInt(it))
    let ansArr = []
    for (let i = 0; i < n; i += 1) {
        let ans = 0
        for (let j = 0; j < n; j += 1) {
            if (i == j) continue
            ans ^= a[j]
        }
        ansArr.push(ans)
    }
    console.log(ansArr.join(' '))
})()
//  [javascript]
function Main(input) {
  input = input.replace(/\n/g, ' ');
  input = input.split(" ");
  var A = Number(input[0]);
  input.shift();
  var all=input[0];
  for(var i=1;i<A;i++){
    all^=Number(input[i]);
  }
  console.log(input.map(i=>all^i).join(' '));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	n := sint64()
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	total := int64(0)
	for _, ai := range a {
		total ^= ai
	}
	for _, ai := range a {
		printf("%d ", total^ai)
	}
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	s := 0
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
		s ^= a[i]
	}

	wr := bufio.NewWriter(os.Stdout)
	for i, v := range a {
		wr.WriteString(strconv.Itoa(s ^ v))
		if i < len(a)-1 {
			wr.WriteString(" ")
		} else {
			wr.WriteString("\n")
		}
	}
	wr.Flush()
}
//  [go]
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]uint32, n)
	var x uint32
	for i := 0; i < n; i++ {
		aa[i] = uint32(getNextInt(scanner))
		x = x ^ aa[i]
	}
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, x^aa[i])
	}
}
//  [go]
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	if err := io.writer.Flush(); err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	A := make([]int, N)
	for idx := range A {
		A[idx] = io.NextInt()
	}
	R := make([]int, N)
	for idx := range R {
		xxx := make([]int, N)
		copy(xxx, A)
		xxx = append(xxx[:idx], xxx[idx+1:]...)
		for _, xx := range xxx {
			R[idx] = R[idx] ^ xx
		}
	}
	io.PrintIntLn(R)
}
//  [go]
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	if err := io.writer.Flush(); err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	A := make([]int, N)
	for idx := range A {
		A[idx] = io.NextInt()
	}
	R := make([]int, N)
	for idx := range R {
		for i := 0; i < len(R); i++ {
			if i == idx {
				continue
			}
			R[idx] = R[idx] ^ A[i]
		}
	}
	io.PrintIntLn(R)
}
//  [go]
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N int
  var A []int
  NextInt(&N)
  NextIntSlice(&A)
  a := MaxInt(A...)
  X := 0
  for _, a := range A { X ^= a }
  B := make([]int, N)
  for i, a := range A {
    B[i] = X ^ a
  }
  WriteIntSlice(B)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  Write(B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}
//  [ruby]
def int_split(line); line.split(' ').map(&:to_i); end
def cin_ina; int_split(gets); end

n=gets.to_i
a=cin_ina
large_a = a.inject(:^)
b=a.map{|ai| large_a^ai}
puts b.join(' ')
//  [ruby]
N=gets.to_i
A=gets.split.map(&:to_i)
sum=A.inject(:^)
puts A.map{|a|sum^a}*" "
//  [ruby]
n = gets.to_s.to_i
a = gets.to_s.split.map{ |v| v.to_i }

mask = a.inject(:^)
puts a.map{ _1 ^ mask }.join(" ")
//  [ruby]
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

sum = [0] * 30
onoono = []
sunuke = [0] * N
count = 0

a.each do |i|
  arr = [0] * 30
  (0..29).reverse_each do |j|
    if i >= 2**j
      i -= 2**j
      arr[j] += 1
      sum[j] += 1
      if sum[j] == 2
        sum[j] = 0
      end
    end
  end
  onoono[count] = arr
  count += 1
end

(0...N).each do |k|
  (0..29).each do |l|
    num = (sum[l] + onoono[k][l]) % 2
    if num == 0
      next
    else
      sunuke[k] += num * (2**l)
    end
  end
end

puts sunuke.join(" ")
//  [ruby]
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

sum = [0] * 18
onoono = []
sunuke = [0] * N
count = 0

a.each do |i|
  arr = [0] * 18
  (0..17).reverse_each do |j|
    if i >= 2**j
      i -= 2**j
      arr[j] += 1
      sum[j] += 1
      if sum[j] == 2
        sum[j] = 0
      end
    end
  end
  onoono[count] = arr
  count += 1
end

(0...N).each do |k|
  (0..17).each do |l|
    num = (sum[l] + onoono[k][l]) % 2
    if num == 0
      next
    else
      sunuke[k] += num * (2**l)
    end
  end
end

puts sunuke.join(" ")
//  [ruby]
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

sum = [0] * 18
onoono = []
sunuke = [0] * N
count = 0

a.each do |i|
  arr = [0] * 18
  (0..17).reverse_each do |j|
    if i >= 2**j
      i -= 2**j
      arr[j] += 1
      sum[j] += 1
    end
  end
  onoono[count] = arr
  count += 1
end

(0...N).each do |k|
  (0..17).each do |l|
    num = ((sum[l] + onoono[k][l]) % 2) * (2**l)
    if num == 0
      next
    elsif ((sum[l] + onoono[k][l]) % 2) == 1
      sunuke[k] += num
    end
  end
end

puts sunuke.join(" ")
//  [rust]
#![allow(unused_imports)]
#![allow(unused_macros)]
// use proconio::input;
use std::cmp::Ordering::*;
use std::collections::{BTreeMap, BTreeSet};
use std::io::{self, BufWriter, Write};
use std::str::{self, SplitAsciiWhitespace};

// I have no idea what I'm doing

macro_rules! answer {
    ($out:ident, $ans:expr) => {
        writeln!($out, "{}", $ans)
    };
}

fn main() -> Result<(), io::Error> {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = BufWriter::new(stdout.lock());

    let n: usize = scan.token();
    let a: Vec<_> = (0..n).map(|_| scan.token::<u32>()).collect();

    let xor = a.iter().fold(0, |acc, &x| acc ^ x);

    for x in a {
        write!(out, "{} ", xor ^ x)?;
    }
    writeln!(out)
}

///////////////////////////////////////////////////////////////////////////////////////////////////

/// Mostly copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> UnsafeScanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse [Scanner]");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    pub fn pair<T: str::FromStr>(&mut self) -> (T, T) {
        (self.token(), self.token())
    }
}

// aka #![feature(bool_to_option)]
trait BoolThen {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T>;
}

impl BoolThen for bool {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T> {
        if self {
            Some(f())
        } else {
            None
        }
    }
}

trait BoolToYes {
    fn yes(self) -> &'static str;
}

impl BoolToYes for bool {
    fn yes(self) -> &'static str {
        if self {
            "YES"
        } else {
            "NO"
        }
    }
}
//  [rust]
fn main() {
    proconio::input! {
        n: usize,
        a: [u32;n],
    }
    let x=a.iter().fold(0,|x,a|x^a);
    println!("{}",itertools::join(a.into_iter().map(|a|a^x), " "));
}
//  [rust]
use std::io::stdin;

#[derive(Default)]
struct Scanner {
	buffer: Vec<String>
}

impl Scanner {
	fn next<T: std::str::FromStr> (&mut self) -> T {
		loop {
			if let Some(token) = self.buffer.pop() {
				return token.parse().ok().expect("Failed parse");
			}
			let mut input = String::new();
			stdin().read_line(&mut input).expect("Failed read");
			self.buffer = input.split_whitespace().rev().map(String::from).collect();
		}
	}
}

fn main() {
	let mut scan = Scanner::default();
	let n: usize = scan.next();
	let mut a: Vec<u32> = vec![0;n];
	let mut ans: Vec<u32> = vec![0;n];
	for i in 0..n {
		a[i] = scan.next();
		for j in 0..n {
			if i != j { ans[j] ^= a[i] };
		}
	}
	for i in 0..n {
		if i > 0 { print!(" {}", ans[i]); }
		else { print!("{}", ans[i]); }
	}
	println!("");
}
//  [rust]
use std::io::stdin;

#[derive(Default)]
struct Scanner {
	buffer: Vec<String>
}

impl Scanner {
	fn next<T: std::str::FromStr> (&mut self) -> T {
		loop {
			if let Some(token) = self.buffer.pop() {
				return token.parse().ok().expect("Failed parse");
			}
			let mut input = String::new();
			stdin().read_line(&mut input).expect("Failed read");
			self.buffer = input.split_whitespace().rev().map(String::from).collect();
		}
	}
}

fn main() {
	let mut scan = Scanner::default();
	let n: usize = scan.next();
	let mut a: Vec<u32> = vec![0;n];
	for i in 0..n {
		a[i] = scan.next();
	}
	for i in 0..n {
		let mut ans = 0;
		for j in 0..n {
			if i != j {
				ans ^= a[j];
			}
		}
		if i != 0 { print!(" {}", ans); }
		else { print!("{}", ans); }
	}
	println!("");
}
//  [rust]
use proconio::input;

const alpha: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];

const Alpha: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];

fn main() {
    input!(n: usize);
    input!(a: [usize; n]);
    let sum = a.iter().fold(0, |acc, &e| acc ^ e);
    let mut ans = vec![];
    for i in 0..n {
        ans.push(sum ^ a[i]);
    }
    for i in 0..n {
        print!("{} ", a[i]);
    }
}
//  [swift]
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}


func main() {
    let n = Int(readLine()!)!
    let A = readWords { Int($0)! }

    // ans: a b c d
    // inp: b^c^d a^c^d a^b^d a^b^c
    // b^c^d ^ a^c^d --> a^b
    // a^b^d ^ a^b --> d
    // 他のやつ全部でxorとればOK
    // いったん全部のxor取得 -> それに対して各要素とxorをとる

    let total = A.reduce(0, ^)
    print(A.map { (total^$0).description }.joined(separator: " "))
}


main()
//  [swift]
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}


let _ = {
    let n = Int(readLine()!)!
    let A = readWords { Int($0)! }

    let total = A.reduce(0, ^)
    print(A.map { (total^$0).description }.joined(separator: " "))
}()
//  [typescript]
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  let  n:number = next();
  let  morty:number[] = nexts(n);
  let rick:number[] = [];
  let tmp:nember = morty[0];
  let i ;
  for(i = 1;i<morty.length;i++){
    
  	tmp^=morty[i];
  }
  for( i  = 0;i<morty.length;i++){
    
    let x = morty[i]^tmp;
    rick.push(x)
  }
  return rick.join(" ");
}
//  [typescript]
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N] = r.nn()
    const a = r.nn()

    let xsum = a[0]

    for (let i = 1; i < N; i++) {
      xsum = xsum ^ a[i]
    }
    const res = a.map((ai) => {
      return ai ^ xsum
    })

    return res.join(' ')
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}
//  [typescript]
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  let  n:number = next();
  let  morty:number[] = nexts(n);
  let rick:number[] = [];
  let tmp:nember = morty[0];
  for(var i = 1;i<morty.length;i++){
    
  	tmp^=morty[i];
  }
  for( var i  = 0;i<morty.length;i++){
    
    let x = morty[i]^tmp;
    rick = [...rick,x]
  }
  return rick.join(" ");
}
//  [typescript]
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  let  n:number = next();
  let  morty:number[] = nexts(n);
  let rick:number[] = [];
  let tmp:nember = morty[0];
  let i ;
  for(i = 1;i<morty.length;i++){
    
  	tmp^=morty[i];
  }
  for( i  = 0;i<morty.length;i++){
    
    let x = morty[i]^tmp;
    rick = [...rick,x]
  }
  return rick.join(" ");
}
//  [typescript]
import { readFileSync } from "fs";
 
const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));
 
const main = (input: string[][]) => {
  const n = parseInt(input[0][0]);
  const morty:number[] = input[1].map(x=>parseInt(x));
  let tmp:nember = morty[0];
  let i ;
  for(i = 1;i<morty.length;i++){
    
  	tmp^=morty[i];
  }
 let rick:number[] = [];
  for( i  = 0;i<morty.length;i++){
    
    let x = morty[i]^tmp;
    rick = [...rick,x]
  }
  
  return rick.join(' ')
};


console.log(main(read()));
//  [python]
n=int(input());print(n*-~n>>1)
//  [python]
N = int(input())

result = 0
for i in range(1,N+1):
  result += i

print(result)
//  [python]
num = int(input())

ans = 0
for i in range(num+1):
  ans += i
print(ans)
//  [python]
N = int(input())

ans = 0

for i in range(N):
    ans += i
print(ans)
//  [python]
N = int(input())
 
candy=(1+N)*N/2
print(candy)
//  [python]
N = int(input())

candy=N*(1+N)/2
print(candy)
//  [java]
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int N = Integer.parseInt(s);

            System.out.println((1 + N) * N /2);
        }
    }
}
//  [java]
import java.util.Scanner;
class T1{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count=0;
        for(int i=1;i<=n;i++){
            count = count+i;

        }System.out.println(count);

    }
}
//  [java]
class hi{
public static void main(String[] args){
System.out.println("Hello world");
}

}
//  [java]
import java.util.*;

public class Main{

	public static void main(String[] args){
      
      Scanner scan = new Scanner(System.in);
      String Input = scan.next();
      String[] lists = Input.split("");
      
      
      
      ArrayList<String> Array = new ArrayList<String>();  
      
     
      
      
      for (int i=0; i<lists.length; i++){
        if(lists[i].equals("B") && Array.size()>0 ){
          try{
          if(lists[i+1].equals("B")){
           // System.out.print("pass");  
          }
          else{
            Array.add(lists[i]);
          }
          }catch (ArrayIndexOutOfBoundsException e){
            Array.add(lists[i]);
          }
        }
        else{
          //System.out.println(lists[i]);
          Array.add(lists[i]);
        }
      }
    // System.out.println(Array);
     
      
      
     for (int j=0; j<Array.size(); j++){
      try{
       if (Array.get(j).equals("B")){
       }
       else if(j>0 && Array.get(j+1).equals("B")){
       }
       else{
         System.out.print(Array.get(j));
       }
      }catch (IndexOutOfBoundsException e){
        System.out.print(Array.get(j));
      }
       
    }
}
}
//  [cpp]
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	printf("%d",(n+1)*n/2);
}
//  [cpp]
#include<cstdio>
int main(void)
{
    int i,n;
    while(~scanf("%d",&n))
    {
        int sum=0;
        for(i=1;i<=n;i++) sum+=i;
        printf("%d\n",sum);
    }
    return 0;
}
//  [cpp]
#include"stdio.h"
#include"cstdio"
#include"algorithm"
#include"string.h"
using namespace std;
typedef long long ll; 
int main()
{
	ll n;
	while(scanf("%d",&n)!=EOF)
	{
		ll ret=(n+1)*n/2;
		printf("%lld\n",ret);
	}
}
//  [cpp]
#include <iostream>
using namespace std;
int  main()
{
int  n,s;
cin >> n;
for(int i=1;i<=n;i++)
{
s+=i;
}
cout << s;
return 0;
}
//  [cpp]
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second

using namespace std;

int main(){
  int n;
  cin >> n;
  vi dp(n);
  dp[0] = 1;
  Lrep(i,1,100) dp[i] = dp[i-1] + i + 1;
  cout << dp[n-1] << endl;
}
p
//  [cpp]
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second

using namespace std;

int main(){
  int n;
  vi dp(n);
  dp[0] = 1;
  Lrep(i,1,100) dp[i] = dp[i-1] + i + 1;
  cout << dp[n-1] << endl;
}
//  [c]
#include <stdio.h>

int main(void)
{
    int i,n,result;
    scanf("%d", &n);
    for(result=0,i=1;i<=n;i++){
        result += i;
    }
    printf("%d\n",result);

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

    int n,i,sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        sum=sum+i;
    }
    printf("%d\n",sum);
    return 0;
}
//  [c]
#include<stdio.h>

int main()
{
	
	int i, N, total;
	
	scanf("%d",&N);
	
	total = (N*(N+1))/2;
	
	printf("%d",total);
	
	return 0;
}
//  [c]
#include<stdio.h>
main()
{
    int N,i,sum=0;
    printf("Enter the number of students ");
    scanf("%d", &N);
    for(i=1; i<=N; i++)
    {
        sum=sum+i;
    }
    printf("%d\n",sum);
    return 0;
}
//  [c]
#include <stdio.h>

int main()

{
int n,i,sum;

scanf("%d",&n);


for(i=1;i<=n;i++)
{
sum=sum+i;
}
printf("%d",sum);

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

int main(void){
  int N, sum = 0;
  scanf("%d", &N);
  for(int n; n < N; n++){
    sum = sum + n + 1;
  }
  printf("%d\n", sum);
  return 0;
}
//  [javascript]
function Main(input) {
  const data = parseInt(input, 10);
  var sum = 0;
  for (var i = 1; i <= data; i++) {
    sum += i;
  }
  console.log(sum);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  const data = parseInt(input, 10);
  var sum = 0;
  for (var i = 1; i <= data; i++) {
    sum += i;
  }
  console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var ans =0;
  for(i=1;i<=n;i++){
    ans+=i;
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
  input = input.trim();
  const a = input.split("").map(Number);
  console.log(a*(a+1)/2);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(a) {
  console.log(a*(a+1)/2);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(a) {
  a = a.trim();
  console.log(a*(a+1)/2);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import(
	"fmt"
)

func main () {
	var a int
	var ans int

	fmt.Scan(&a)

	for i := 0; i <= a; i++{
		ans += i
	}

	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ret := 0
	for i := 1; i <= n; i++ {
		ret += i
	}

	fmt.Println(ret)
}
//  [go]
package main

import (
	"fmt"
	"strings"
)

func main() {
	var str string
	fmt.Scan(&str)

	slice := strings.Split(str, "")

	//fmt.Printf("%s\n", slice)

	ans := []string{}
	for i, x := range slice {
		if x != "B" {
			ans = append(ans, x)
		} else if i != 0 && x == "B" {
			length := len(ans)
			if length != 0 {
				ans = ans[:length-1]
			}
		}
	}
	r := strings.Join(ans, "")
	fmt.Println(r)
}
//  [go]
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ss := strings.Split(sc.Text(), " ")

	nl := []float64{}
	for _, i := range ss {
		m, _ := strconv.ParseFloat(i, 64)
		nl = append(nl, m)
	}

	res := math.MaxFloat64
	for i := -100; i <= 100; i++ {
		r := 0.0
		for _, x := range nl {
			r += math.Pow(x - float64(i), 2)
		}
		if res > r {
			res = r
		}
	}
	fmt.Println(int(res))
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
  	var ans int
  fmt.Scan(&n)
  
  for i := 0; i < n; i++ {
  	ans += i
  }
  
  fmt.Println(ans)
}
//  [ruby]
a = gets.to_i
x = (0..a).inject(&:+)
puts x
//  [ruby]
N = gets.to_i
puts [*1..N].inject(:+)
//  [ruby]
n = gets.chomp.to_i
i = 0
sum = 0
while i <= n
  sum += i
  i += 1
end
puts sum
//  [ruby]
s = gets.chomp
ans = []
for i in 0..(s.length - 1)
  if s[i] == "B"
    if ans.size != 0
      ans.delete_at(ans.size - 1)
    end
  else
    ans.push(s[i])
  end
end
puts ans.reverse.join
//  [ruby]
n = gets.to_i
puts (n/2)*(n + 1)
//  [ruby]
ABC = gets.split.map(&:to_i)
puts (ABC.count(5) == 2 && ABC.count(7) == 1) ? 'YES' : 'NO'
//  [rust]
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let n: usize = s.trim().parse().unwrap();

    println!("{}", n * (n + 1) / 2);
}
//  [rust]
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let n = line.trim().parse::<u16>().unwrap();
    let sum = (0..n+1).fold(0, |a, i| a + i);
    println!("{}", sum);
}
//  [rust]
fn main() {
    let n = read_i64();
    println!("{}", solve(n));
}

fn solve(n : i64) -> i64 {
    n * (n + 1) / 2
}

fn read_i64() -> i64 {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf);
    buf.trim().parse().unwrap()
}
//  [rust]
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let mut v = Vec::new();

    for char in line.trim().chars() {
        match char {
            'B' => { v.pop(); },
            c if c == '0' || c == '1' => { v.push(c); },
            _ => () 
        }
    }

    let s = v
        .iter()
        .map(|s| s.to_string())
        .collect::<String>();

    println!("{}", s);
}
//  [rust]
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let n = line.trim().parse::<u8>().unwrap();
    let sum = (0..n+1).fold(0, |a, i| a + i);
    println!("{}", sum);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<i32>();
    println!("{}", (1..=n).fold(0, |sum, i| sum + i));
}
//  [swift]
let N=Int(readLine()!)!;print(N*(N+1)/2)
//  [swift]
print((1...Int(readLine()!)!).reduce(0){$0+$1})
//  [swift]
let n = Int(readLine()!)!
print(n*(n+1)/2)
//  [swift]
print(1...Int(readLine()!)!.reduce(0){$0+$1})
//  [swift]
print(1...Int(readLine)!.reduce(0){$0+$1})
//  [swift]
var ary:[Int] = []
for i in 1...Int(readLine()!)! {
    ary.append(i)
}
print(ary.reduce(0, {x, y in x + y}))
//  [typescript]
import * as fs from "fs";
 
let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
var num = parseInt(input[0])

console.log(num * (num + 1) / 2);
//  [typescript]
function main(input: string) {
  const N: number = Number(input.split("\n")[0]);
  let sum: number = 0;
  for (let i: number = 1; i <= N; i += 1) {
    sum += i;
  }
  console.log(sum);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let n=nin()
  out(n*(n+1)/2)
}
main()
//  [typescript]
const fs = require('fs')
const reader = (s: string) => (s.split(""))
 
function Main(input: string) {
  let aaa = ''
  reader(input).forEach(r=>{
    if(r ==="B")
    {
      if(aaa.length > 0 ) aaa = aaa.slice(0,aaa.length -1)
    }
    else{
      aaa += r
    }
  })
  console.log(aaa)
}
 
Main(fs.readFileSync('/dev/stdin', 'utf8'))
//  [typescript]
'use strict'
const main = (input) => {
  input = input.split('')[0];
  const s = "";
  
  for (const i = 0; i<input.length; i++) {
    if (input[i]=="0") {
      s += "0";
    }else if(input[i]=="1"){
      s += "1"
    }else{
      s = s.slice(0, -1);
    }
  }
  console.log(s);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
'use strict'
const main = (input) => {
  input = input.split('\n')[0].split('');
  const s = "";
  
  for (const i = 0; i<input.length; i++) {
    if (input[i]=="0") {
      s += "0";
    }else if(input[i]=="1"){
      s += "1"
    }else{
      s = s.slice(0, -1);
    }
  }
  console.log(s);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
n = int(input())
W = list(map(int,input().split()))
sa = sum(W)


for i in range (n):
  if abs(sa-2*W[i])-abs(sa) >0:
    print(abs(sa))
    break
  sa -= 2*W[i]
//  [python]
n = int(input())
a = list(map(int, input().split()))

left = 0
right = sum(a)

ans = 10000
for i in range(1, n):
    left += a[i - 1]
    right -= a[i - 1]
    if abs(left - right) < ans:
        ans = abs(left - right)
    else:
        break

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

mindel = 10000
for i in range(0,n-1):
    dels = abs(sum(w[0:i+1])-sum(w[i+1:n])) 
    if dels<mindel:
        mindel = dels
print(mindel)
//  [python]

url = "https://atcoder.jp//contests/abc129/tasks/abc129_b"

def main():
    n = int(input())
    t = list(map(int, input().split()))
    ans = 1000000000
    sums = sum(t)
    for v in t:
        sums -= v
        ans = min(sums, ans)
    print(ans)


if __name__ == '__main__':
    main()
//  [python]
N = int(input())
W = list(map(int,input().split()))
T = []
for t in range(1,N):
    Q = [W[i] for i in range(t)]
    R = [W[i] for i in range(t,N)]
    T.append(abs(sum(Q)-sum(R)))
    

print(T)
//  [python]
N = int(input())
W = list(map(int,input().split()))
T = []
Q = []
R = []
for t in range(1,N):
    for i in range(N):
        if i <= t-1:
            Q.append(int(W[i]))
        else:
            R.append(int(W[i]))
    sum_Q = sum(Q)
    sum_R = sum(R)
    T.append(abs(sum_Q - sum_R))
   

print(min(T))
//  [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[] W = new int[N + 1];
		for (int i = 1; i <= N; i++)
			W[i] = sc.nextInt();
		int S1 = 0;
		int S2 = 0;
		int max = 0;
		for (int i = 1; i <= N; i++)
			max += W[i];
		int ans = max;

		for (int t = 1; t <= N; t++) {
			for (int i = 1; i <= t; i++) {
				S1 += W[i];
			}
			S2 = max - S1;
			ans = Math.min(ans, Math.abs(S1 - S2));
			S1 = 0;
			S2 = 0;
		}

		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;
	}

	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.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int[] W = new int[N];
        int a = 0;
        int b = 0;
        for (int i=0; i<N; i++) {
            W[i] = reader.nextInt();
            a += W[i];
        }
        int ans = a;
        for (int i=0; i<N; i++) {
            a -= W[i];
            b += W[i];
            ans = Math.min(ans, Math.abs(a-b));
        }
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        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() { return hasNextByte() ? buffer[ptr++] : -1;}
        private 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() {
            return (int)nextLong();
        }
        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.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> omori = new ArrayList<Integer>();
		int n = sc.nextInt();
		for (int i = 0; i <= n - 1; i++) {
			int a = sc.nextInt();
			omori.add(a);
		}
		int weight = 0;
		for (int i = 0; i <= n - 1; i++) {
			weight += omori.get(i);
		}

		int ans=0;
		for (int i = 0; i < n - 1; i++) {
			int zen = 0;
			for (int j = 0; j <= i; j++) {
				zen += omori.get(j);
			
			int kou = weight - zen;

			int zen2 = zen + omori.get(i + 1);
			int kou2 = weight - zen2;

			ans = Math.min(Math.abs(zen2 - kou2), Math.abs(zen - kou));
			}
		}
		System.out.println(ans);

	}
}
//  [java]

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> omori = new ArrayList<Integer>();
		int n = sc.nextInt();
		for (int i = 0; i <= n - 1; i++) {
			int a = sc.nextInt();
			omori.add(a);
		}
		int weight = 0;
		for (int i = 0; i <= n - 1; i++) {
			weight += omori.get(i);
		}

		int ans=0;
		for (int i = 0; i < n - 1; i++) {
			int zen = 0;
			for (int j = 0; j <= i; j++) {
				zen += omori.get(j);
			}
			int kou = weight - zen;

			int zen2 = zen + omori.get(i + 1);
			int kou2 = weight - zen2;

			ans = Math.min(Math.abs(zen2 - kou2), Math.abs(zen - kou));

		}
		System.out.println(ans);

	}
}
//  [java]
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> omori = new ArrayList<Integer>();
		int n = sc.nextInt();
		for (int i = 0; i <= n - 1; i++) {
			int a = sc.nextInt();
			omori.add(a);
		}
		int weight = 0;
		for (int i = 0; i <= n - 1; i++) {
			weight += omori.get(i);
		}

		for (int i = 0; i < n - 1; i++) {
			int zen = 0;
			for (int j = 0; j <= i; j++) {
				zen += omori.get(j);
			}
			int kou = weight - zen;

			int zen2 = zen + omori.get(i + 1);
			int kou2 = weight - zen2;

			ans = Math.min(Math.abs(zen2 - kou2), Math.abs(zen - kou));

		}
		System.out.println(ans);

	}
}