'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(" ").map(x => parseInt(x));
        let a = array[0]
        let b = array[1]
        let c = array[2]

        let length = 2*Math.abs(a-b);
        if (length < Math.max(a,b) || length < c)
            console.log(-1)
        else
            console.log(c > length/2 ? c - length/2 : c + length/2);
    }
}

const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [a1, b1, c1] = d.split(" ").map(Number);
  const diameter = Math.abs(a1 - b1);
  const circle = diameter * 2;

  if (circle < a1 || circle < b1) {
    console.log(-1);
  } else if (c1 > circle) {
    console.log(-1);
  } else {
    const guess = c1 + diameter;
    if (guess > circle) {
      console.log(guess - circle);
    } else {
      console.log(guess);
    }
  }
  c++;
});

rl.on("close", () => {});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
	var t = lines[0];
    for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = k[0]; var b = k[1]; var c = k[2];
        var dif = Math.abs(a - b);
        var v = dif * 2;
        if(a > v || b > v || c > v){
            console.log(-1);
        }else{
            var d = c + dif;
            if(d > v){
                d = c - dif;
            }
            console.log(d);
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
	var t = lines[0];
	var e = 0;
	for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = k[0];
        var b = k[1];
        var c = k[2];
        var dif = Math.abs(a - b);
        var val = dif * 2;
        if(a > val || b > val || c > val){
            console.log(-1);
        }else{
            var d = c + dif;
            if(d > val){
                d = c - dif;
            }
            console.log(d);
        }
	}
});

function main(input) {
    function readline() {
        return input.shift();
    }

    let lines = Number(readline());
    for(let i=0; i<lines; i++) {
        const data = readline().split(' ').map(Number)
        const [a, b, x] = data;

        const offset = Math.abs(a-b)
        const size = offset * 2;

        function getResult(){
            if([a, b, x].every(i => i <= size)) {
                if(x > offset) {
                    return x - offset
                } else {
                    return x + offset
                }
            }
            return '-1';
        }
        console.log(getResult());
    }
}

////////////////////////
let inputString = '';
process.stdin.on('data', (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on('end', (_) => {
    inputString = inputString.trim().split('\n').map((string) => string.trim());

    main(inputString);
});

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

  var t=parseInt(readline())

while(t--){
    var array=readline().split(' ').map(x=>parseInt(x));
    var a=array[0];
    var b=array[1];
    var c=array[2]

    var distance=Math.abs(a-b);
    var n=distance*2;
    if(distance<=1){
        print('-1')
    }else if(n<a || n<b || n<c){
        print('-1')
    }
    else if((distance+c)>n){
        print(c-distance)
    }else{
        print(distance+c)
    }

}

}

function solve() {
   let [a, b, c] = readArray(Number);
   if (a > b) {
      const temp = a;
      a = b;
      b = temp;
   }
   const diff = b - a;
   if (!(a <= diff && b > diff) || c > diff * 2) {
      write(-1);
      return;
   }
   if (c <= diff) {
      write(c + diff);
      return;
   }
   write(c - diff);
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1n;
   while(curN) {
      if (curN & 1n) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1n;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let [a, b, c] = nl.nums();
		let n = Math.abs(a - b) ;
		if (a > n * 2  || b > n * 2 || c > n * 2){
			ans.push(-1);
		} else {
			ans.push(n >= c?(c + n):(c - n))
		}
	}
	console.log(ans.join('\n'));
};

process.stdin.on('end', sol);

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const [a, b, c] = rna();

		const k = Math.abs(a-b);

		let ans = -1;
		if (a <= 2*k && b <= 2*k && c <= 2*k) {
			ans = (c + k - 1) % (2 * k) + 1;
		}

		console.log(ans);
	}
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let [a, b, c] = input[z++].split(' ').map(Number);
        let diff = Math.abs(a - b);
        if((a > diff * 2)){
            console.log(-1);
        }
        else if(b > diff * 2){
            console.log(-1);
        }
        else if(c > diff * 2){
            console.log(-1);
        }
        else{
            let opposite = diff + c <= diff * 2 ? diff + c : Math.abs(diff - c);
            console.log(opposite);
        }
    }
}

abs = Math.abs

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');

let currentline = 0;
function readline(){
    return input[currentline++];
}

function solve() {
    let lis = readline("enter a number").split(" ");
    let a, b, c;
    a = parseInt(lis[0]);
    b = parseInt(lis[1]);
    c = parseInt(lis[2]);
    if (abs(a - b) * 2 < Math.max(a, b, c)) {
        return -1

    } else {
        let x = abs(b-a);
        let ans = (c + x) ;
        if (ans > (x*2)){
            return c-x
        }
        return ans

    }
}
for (let i = parseInt(readline()); i > 0; i--) {
    console.log(solve())
}

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const assert = (condition) => { if (!condition) throw new Error("Assertion failed"); }
const mi = Math.min;
const mx = Math.max;
const mxll = (...args) => args.reduce((m, e) => e > m ? e : m);
const mill = (...args) => args.reduce((m, e) => e < m ? e : m);
const sqll = (v) => { if (v < 0n) throw 'negative input'; if (v < 2n) return v; const dfs = (n, x0) => { let x1 = ((n / x0) + x0) >> 1n; if (x0 === x1 || x0 === (x1 - 1n)) return x0; return dfs(n, x1); }; return dfs(v, 1n); }; // has >> 0
const abs = Math.abs;
const fl = Math.floor;
const int = parseInt;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg2 = Math.log2;
const lg10 = Math.log10;
const ll = BigInt;
const combination = (m, n) => { return factorial(m, n) / factorial(n, n); };
const factorial = (m, n) => { let num = 1n; let cnt = 0; for (let i = ll(m); i > 0; i--) { if (cnt == n) break; num *= i; cnt++; } return num; };
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const bitCount = (n) => { n = n - ((n >> 1) & 0x55555555); n = (n & 0x33333333) + ((n >> 2) & 0x33333333); return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; };
const powmod = (a, b, mod) => { let r = 1n; while (b > 0n) { if (b % 2n == 1) r = r * a % mod; b >>= 1n; a = a * a % mod; } return r; };
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const sortPart = (a, k) => { let l = a.slice(0, k); l.sort((x, y) => x - y); let r = a.slice(k); return l.concat(r); }; // sort first kth
const initialize2DArrayNew = (n, m) => { let data = []; for (let i = 0; i < n; i++) { let tmp = Array(m).fill(0); data.push(tmp); } return data; };
const initialize3DArray = (n, m, p) => { let res = []; for (let i = 0; i < n; i++) { let data = []; for (let j = 0; j < m; j++) { let tmp = new Array(p).fill(0); data.push(tmp); } res.push(data); } return res; };
const stmkey_in = (m) => new Map([...m].sort((x, y) => x[0] - y[0]));
const stmkey_de = (m) => new Map([...m].sort((x, y) => y[0] - x[0]));
const stmvalue_in = (m) => new Map([...m].sort((x, y) => x[1] - y[1]));
const stmvalue_de = (m) => new Map([...m].sort((x, y) => y[1] - x[1]));
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const counter_value_in_indexA_in = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).push(i); } return m; };
const counter_value_in_indexA_de = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).unshift(i); } return m; };
const reverse2 = (s) => { let res = ""; for (let i = s.length - 1; i >= 0; i--) { res += s[i]; } return res; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
const ups = (s, i, c) => s.slice(0, i) + c + s.slice(i + 1);
const isSubsequence = (s, t) => { let sn = s.length; let tn = t.length; let i = j = 0; while (i < sn && j < tn) { if (s[i] == t[j]) { i++; j++; } else { i++; } } return j == tn; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * 08/18/21 morning
 * https://codeforces.com/contest/1560/problem/B
 */
const solve = (a, b, c) => {
    // pr()
    // pr(a, b, c)
    let half = Math.abs(a - b);
    let tot = half * 2;
    // pr("tot", tot)
    if (c > tot || a > tot || b > tot) return pr(-1);
    if (c - half >= 1 && c - half != a && c- half != b) return pr(c - half);
    if (c + half <= tot && c + half != a && c + half != b) return pr(c + half);
    pr(-1);
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t--) {
            solve(input[i][0], input[i][1], input[i][2]);
            i++;
        }
    });
};

main()

let inputs = []

function read() {
    return inputs.pop();
}

function readInt() {
    return parseInt(read());
}

function solve() {
    let test = readInt();
    while (test--) {
        let a = readInt();
        let b = readInt();
        let c = readInt();
        let nn = Math.abs(b - a);
        let n = nn * 2;
        if (n < a || n < b || n < c) {
            console.log(-1);
        }
        else {
            if (0 < c - nn && c - nn != a && c - nn != b) {
                console.log(c - nn);
            }
            else if (c + nn <= n && c + nn != a && c + nn != b) {
                console.log(c + nn);
            }
            else {
                console.log(-1);
            }
        }
    }
}

function main() {
    inputs = inputString.trim().split(/\n| /).map((string) => string.trim());
    inputs.reverse();
    solve();
}

let inputString = '';

process.stdin.on('data', (inputStdin) => { inputString += inputStdin; });

process.stdin.on('end', (_) => { main(); });

function max(a, b) {
  if (a > b) {
    return {
      max: a,
      min: b
    };
  }
  return {
    max: b,
    min: a
  }
}

function solve(a, b, c) {
  const { max: maxValue, min: minValue } = max(a, b);
  const n = (maxValue - minValue) * 2;
  if (maxValue < (n / 2 + 1)) {
    return -1;
  }
  if (minValue >= (n / 2 + 1)) {
    return -1;
  }
  let res = -1;
  if (c < (n / 2 + 1)) {
    res = n / 2 + c;
    if (res < (n / 2 + 1)) {
      return -1;
    }
  } else {
    res = c - n / 2;
    if (res >= (n / 2 + 1)) {
      return -1;
    }
  }
  return res;
}

function main(array) {
  const T = array[0];
  for (let i = 0; i < T; i++) {
    const arr = array[i + 1];
    const [a, b, c] = arr.split(' ').map((item) => parseInt(item, 10));
    console.log(solve(a, b, c));
  }
}

let inputString = '';

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString.trim().split('\n').map((string) => string.trim());

  main(inputString);
});

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var A = nextInt();
		var B = nextInt();
		var tmp1 = Math.min(A, B);
		var tmp2 = Math.max(A, B);
		A = tmp1;
		B = tmp2;
		var C = nextInt();
		if(Math.abs(A - B) == 1){
			myout(-1);
			continue;
		}
		var size = Math.abs(A - B) * 2;
		if(size < C || size < A || size < B){
			myout(-1);
			continue;
		}
		var low = B - (size / 2);
		var high = B + (size / 2);
		if(high > size){
			high -= size;
		}
		if(low != high){
			myout(-1);
			continue;
		}
		var nx = C + (size / 2);
		if(nx > size){
			nx -= size;
		}
		myout(nx);
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 2 * 1e5 + 10
var mod = BigInt(1e9 + 7)

function main() {
  const xx = readline();
  var array = []
  var i = 0
  while (true) {
    i++
    if (array.length === 1000) break
    if (i % 3 === 0 || i % 10 === 3) continue
    array.push(i)

  }
  // console.log(array)
  Array(Number(xx)).fill(1).map((t, i) => {
    // var n = parseInt(readline());

    var [a, b, c] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    })
    var dd = Math.abs(b - a)

    var max = dd * 2
    if (max < a || max < b || max < c) return console.log(-1)
    var answer = (c + dd) % (max)

    if(c === dd) return  console.log(max)
    if(c === max) return  console.log(dd)
    console.log(answer)
  })
}

'use strict'
Object.defineProperty(exports, '__esModule', { value: !0 })
var os = require('os')
const stdin = process.stdin,
  stdout = process.stdout,
  integerRegex = /-?\d+/g,
  decimalRegex = /-?\d+(?:\.\d+)?/g
class InputAndOutput {
  lineIndex = 0
  lines = []
  dried() {
    return this.lineIndex >= this.lines.length
  }
  readLine() {
    const e = this.lines[this.lineIndex]
    return (this.lineIndex += 1), e
  }
  readLineAsNumber() {
    return Number(this.readLine())
  }
  readIntegersOfLine() {
    const e = this.readLine().match(integerRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  readNumsOfLine() {
    const e = this.readLine().match(decimalRegex)
    return null == e ? [] : e.map(e => Number(e))
  }
  print(e) {
    stdout.write(String(e))
  }
  println(e) {
    stdout.write(String(e)), stdout.write('\n')
  }
  async init() {
    const e = await this.readLines()
    this.lines = e
  }
  readLines() {
    const e = []
    return new Promise(n => {
      stdin.on('data', n => e.push(n)),
        stdin.on('end', function () {
          const t = e.join('').split(os.EOL)
          n(t)
        })
    })
  }
}
async function __main__(e) {
  const n = new InputAndOutput()
  await n.init(), e(n)
}
function solve(e, n, t) {
  const s = Math.abs(e - n)
  if (e > s && n > s) return -1
  const i = 2 * s
  return t > i ? -1 : t + s <= i ? t + s : t - s >= 1 ? t - s : -1
}
__main__(function (e) {
  const n = e.readLineAsNumber()
  for (let t = 1; t <= n; ++t) {
    const [n, t, s] = e.readIntegersOfLine(),
      i = solve(n, t, s)
    e.print(i + '\n')
  }
})

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    for (let i = 0; i < t; i++) {
        const [a, b, c] = lines[l++].trim().split(' ').map(Number)
        console.log(solve(a, b, c))
    }
// })()
})

function solve(a, b, c) {
    const k = Math.abs(a - b)
    const n = 2 * k
    // console.log(n, a, b)
    if (a > n || b > n) return -1
    if (c > n || c + k > n && c - k < 1) return -1

    if (c + k <= n) {
        return c + k
    } else {
        return c - k
    }
}

var t = Number(readline());

while (t--) {
    var arr = readline().split(" ");
    var a = Number(arr[0]);
    var b = Number(arr[1]);
    var c = Number(arr[2]);
    var ppl = Math.abs(a - b) * 2;
    var ans1 = c + ppl / 2;
    var ans2 = c - ppl / 2;

    if (Math.max(a, b) > ppl || c > ppl)
        print(-1);
    else if (ans1 <= ppl)
        print(ans1);
    else if (ans2 >= 1 && ans2 <= ppl)
        print(ans2);
    else
        print(-1);

}

var t = parseInt(readline());
function formate(v) {return  parseInt(v)}
for(i=0;i<t;++i){
    var list = readline().split(' ').map(formate);
    var a = list[0];
    var b = list[1];
    var c = list[2];
    var size = Math.abs(a - b) * 2;

    if (a > size || b > size || c > size) print(-1);
    else print((c + a - b + size - 1)% size + 1);
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var v = args[i].split(" ").map((n) => parseInt(n, 10));
        var a = v[0], b = v[1], c = v[2];
        if (a > b) {
            [a, b] = [b, a];
        }
        if (2 * a > b) {
            console.log(-1);
            continue;
        }
        var n = 2 * b - 2 * a;
        var d = b - a;
        if (c > n) { console.log(-1); }
        else if (c + d <= n) { console.log(c + d); }
        else if (c - d <= 0) { console.log(-1); }
        else if (c - d > n) { console.log(-1); }
        else { console.log(c - d); }
    }
}

// Aujubillhi minassaitoanir rajim Vismillahir Rahmanir Rahim (Allah Hu Ackbar) Allah is Greatest.

// var t = Number(readline());

// for (var i = 1; i <= t; i++) {
//     // var a = Number(readline()),
//     //     b = Number(readline()),
//     //     c = Number(readline());
//     var arr = readline().split(' ').map(x => parseInt(x));
//     var a = arr[0],
//         b = arr[1],
//         c = arr[2];
//     var sub = 0;
//     if (a > b) {
//         sub = a - b;
//     } else {
//         sub = b - a;
//     }

//     if (sub * 2 === 2) {
//         console.log(-1);
//     } else if (a > sub * 2 || c > sub * 2) {
//         console.log(-1);
//     } else {
//         var spe1 = c - sub;
//         if (spe1 == 1) {
//             // var spe1 = c - sub;
//             console.log(spe1);
//         } else {
//             var spe2 = sub + sub;
//             console.log(spe2);
//         }
//     }

// }

// var a = Number(readline()),
//         b = Number(readline()),
//         c = Number(readline());

// var t = Number(readline());
// for (var i = 1; i <= t; i++) {
//     var arr = readline().split(' ').map(x => parseInt(x));
//     var a = arr[0],
//         b = arr[1],
//         c = arr[2];
//     let nn = Math.abs(b - a);
//     let n = nn * 2;
//     if (n < a || n < b || n < c) {
//         console.log(-1);
//     } else {
//         if (0 < c - nn && c - nn != a && c - nn != b) {
//             console.log(c - nn);
//         } else if (c + nn <= n && c + nn != a && c + nn != b) {
//             console.log(c + nn);
//         } else {
//             console.log(-1);
//         }
//     }
// }

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});

function readline() {
    return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

    var t = Number(readline());
    for (var i = 1; i <= t; i++) {
        var arr = readline().split(' ').map(x => parseInt(x));
        var a = arr[0],
            b = arr[1],
            c = arr[2];
        let nn = Math.abs(b - a);
        let n = nn * 2;
        if (n < a || n < b || n < c) {
            console.log(-1);
        } else {
            if (0 < c - nn && c - nn != a && c - nn != b) {
                console.log(c - nn);
            } else if (c + nn <= n && c + nn != a && c + nn != b) {
                console.log(c + nn);
            } else {
                console.log(-1);
            }
        }
    }

}

// let inputs = []

// function read() {
//     return inputs.pop();
// }

// function readInt() {
//     return parseInt(read());
// }

// function solve() {
//     let test = readInt();
//     while (test--) {
//         let a = readInt();
//         let b = readInt();
//         let c = readInt();
//         let nn = Math.abs(b - a);
//         let n = nn * 2;
//         if (n < a || n < b || n < c) {
//             console.log(-1);
//         }
//         else {
//             if (0 < c - nn && c - nn != a && c - nn != b) {
//                 console.log(c - nn);
//             }
//             else if (c + nn <= n && c + nn != a && c + nn != b) {
//                 console.log(c + nn);
//             }
//             else {
//                 console.log(-1);
//             }
//         }
//     }
// }

// function main() {
//     inputs = inputString.trim().split(/\n| /).map((string) => string.trim());
//     inputs.reverse();
//     solve();
// }

// let inputString = '';

// process.stdin.on('data', (inputStdin) => { inputString += inputStdin; });

// process.stdin.on('end', (_) => { main(); });

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
  let numOfTimes = readline();
  let line;
  while (numOfTimes--) {
    line = readline();
    print(work(...convert(line.split(" "))));
  }
}

function convert(arr){
    return arr.map((ele)=> Number(ele));

}

function work(a, b, c) {
  const max = Math.max(a, b);
  const half = 2 * max - a - b;

  if (max > 2 * half || c > 2 * half) return -1;

  if (c > half) {
    return c - half;
  } else {
    return c + half;
  }
}

var t = Number(readline());

while (t--) {
    var arr = readline().split(" ");
    var a = Number(arr[0]);
    var b = Number(arr[1]);
    var c = Number(arr[2]);
    var ppl = Math.abs(a - b) * 2;
    var ans1 = c + ppl / 2;
    var ans2 = c - ppl / 2;

    if (Math.max(a, b) > ppl)
        print(-1);
    else if (ans1 <= ppl)
        print(ans1);
    else if (ans2 >= 1 && ans2 <= ppl)
        print(ans2);
    else
        print(-1);

}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(" ").map(x => parseInt(x));
        let a = array[0]
        let b = array[1]
        let c = array[2]

        let length = 2*(a-b);
        if (length < Math.max(a,b) || length < c)
            console.log(-1)
        else
            console.log(c > length/2 ? c - length/2 : c + length/2);
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(" ").map(x => parseInt(x));
        let a = array[0]
        let b = array[1]
        let c = array[2]

        let length = 2*(a-b);
        if (length < Math.max(a,b) || length < c){
            console.log(-1)
            continue;
        }

        console.log(c > length/2 ? c - length/2 : c + length/2);
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(" ").map(x => parseInt(x));
        let a = array[0]
        let b = array[1]
        let c = array[2]

        let length = 2*(a-b);
        if (length < Math.max(a,b,c)){
            console.log(-1)
            continue;
        }

        console.log(c > length/2 ? c - length/2 : c + length/2);
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(" ").map(x => parseInt(x));
        let a = array[0]
        let b = array[1]
        let c = array[2]

        let length = 2*(a-b);
        if (length < Math.max(a,b) || length < c){
            console.log(-1)
        }

        console.log(c > length/2 ? c - length/2 : c + length/2);
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(" ").map(x => parseInt(x));
        let a = array[0]
        let b = array[1]
        let c = array[2]

        let length = 2*(a-b);
        if (length < Math.max(a,b,c)){
            console.log(-1)
        }

        console.log(c > length/2 ? c - length/2 : c + length/2);
    }
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var v = args[i].split(" ").map((n) => parseInt(n, 10));
        var a = v[0], b = v[1], c = v[2];
        if (a > b) {
            [a, b] = [b, a];
        }
        if (2 * a > b) {
            console.log(-1);
            continue;
        }
        var n = 2 * a - 2 * b;
        var d = b - a;
        if (c > n) { console.log(-1); }
        else if (c + d <= n) { console.log(c + d); }
        else if (c - d <= 0) { console.log(-1); }
        else if (c - d > n) { console.log(-1); }
        else { console.log(c - d); }
    }
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var v = args[i].split(" ").map((n) => parseInt(n, 10));
        var a = v[0], b = v[1], c = v[2];
        if (a > b) {
            [a, b] = [b, a];
        }
        if (2 * a > b) {
            console.log(-1);
            continue;
        }
        var n;
        for (var j = 0; j <= 10000; j++) {
            if (2 * (a + j) === b + j) {
                n = b + j;
            }
        }
        var d = b - a;
        if (c > n) { console.log(-1); }
        else if (c + d <= n) { console.log(c + d); }
        else if (c - d <= 0) { console.log(-1); }
        else if (c - d > n) { console.log(-1); }
        else { console.log(c - d); }
    }
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var v = args[i].split(" ").map((n) => parseInt(n, 10));
        var a = v[0], b = v[1], c = v[2];
        if (a > b) {
            [a, b] = [b, a];
        }
        if (2 * a > b) {
            console.log(-1);
            continue;
        }
        var n;
        for (var j = 0; j <= 10000; j++) {
            if (2 * (a + j) === b + j) {
                n = b + j;
            }
        }
        var d = b - a;
        if (c + d <= n) { console.log(c + d); }
        else if (c - d <= 0) { console.log(-1); }
        else if (c - d > n) { console.log(-1); }
        else { console.log(c - d); }
    }
}

// Aujubillhi minassaitoanir rajim Vismillahir Rahmanir Rahim (Allah Hu Ackbar) Allah is Greatest.

// var t = Number(readline());

// for (var i = 1; i <= t; i++) {
//     // var a = Number(readline()),
//     //     b = Number(readline()),
//     //     c = Number(readline());
//     var arr = readline().split(' ').map(x => parseInt(x));
//     var a = arr[0],
//         b = arr[1],
//         c = arr[2];
//     var sub = 0;
//     if (a > b) {
//         sub = a - b;
//     } else {
//         sub = b - a;
//     }

//     if (sub * 2 === 2) {
//         console.log(-1);
//     } else if (a > sub * 2 || c > sub * 2) {
//         console.log(-1);
//     } else {
//         var spe1 = c - sub;
//         if (spe1 == 1) {
//             // var spe1 = c - sub;
//             console.log(spe1);
//         } else {
//             var spe2 = sub + sub;
//             console.log(spe2);
//         }
//     }

// }

// var t = Number(readline());
// for (var i = 1; i <= t; i++) {
//     var a = Number(readline()),
//         b = Number(readline()),
//         c = Number(readline());
//     let nn = Math.abs(b - a);
//     let n = nn * 2;
//     if (n < a || n < b || n < c) {
//         console.log(-1);
//     } else {
//         if (0 < c - nn && c - nn != a && c - nn != b) {
//             console.log(c - nn);
//         } else if (c + nn <= n && c + nn != a && c + nn != b) {
//             console.log(c + nn);
//         } else {
//             console.log(-1);
//         }
//     }
// }

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});

function readline() {
    return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

    var t = Number(readline());

    for (var i = 1; i <= t; i++) {
        // var a = Number(readline()),
        //     b = Number(readline()),
        //     c = Number(readline());
        var arr = readline().split(' ').map(x => parseInt(x));
        var a = arr[0],
            b = arr[1],
            c = arr[2];
        var sub = 0;
        if (a > b) {
            sub = a - b;
        } else {
            sub = b - a;
        }

        if (sub * 2 === 2) {
            console.log(-1);
        } else if (a > sub * 2 || c > sub * 2) {
            console.log(-1);
        } else {
            var spe1 = c - sub;
            if (spe1 == 1) {
                // var spe1 = c - sub;
                console.log(spe1);
            } else {
                var spe2 = sub + sub;
                console.log(spe2);
            }
        }

    }

}

// Aujubillhi minassaitoanir rajim Vismillahir Rahmanir Rahim (Allah Hu Ackbar) Allah is Greatest.

// var t = Number(readline());
// for (var i = 1; i <= t; i++) {
//     var a = Number(readline()),
//         b = Number(readline()),
//         c = Number(readline());
//     let nn = Math.abs(b - a);
//     let n = nn * 2;
//     if (n < a || n < b || n < c) {
//         console.log(-1);
//     } else {
//         if (0 < c - nn && c - nn != a && c - nn != b) {
//             console.log(c - nn);
//         } else if (c + nn <= n && c + nn != a && c + nn != b) {
//             console.log(c + nn);
//         } else {
//             console.log(-1);
//         }
//     }
// }

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});

function readline() {
    return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

    var t = Number(readline());
    for (var i = 1; i <= t; i++) {
        var a = Number(readline()),
            b = Number(readline()),
            c = Number(readline());
        let nn = Math.abs(b - a);
        let n = nn * 2;
        if (n < a || n < b || n < c) {
            console.log(-1);
        } else {
            if (0 < c - nn && c - nn != a && c - nn != b) {
                console.log(c - nn);
            } else if (c + nn <= n && c + nn != a && c + nn != b) {
                console.log(c + nn);
            } else {
                console.log(-1);
            }
        }
    }
}

// Aujubillhi minassaitoanir rajim Vismillahir Rahmanir Rahim (Allah Hu Ackbar) Allah is Greatest.

// var t = Number(readline());
// for (var i = 1; i <= t; i++) {
//     var a = Number(readline()),
//         b = Number(readline()),
//         c = Number(readline());
//     var sub = 0;
//     if (a > b) {
//         sub = a - b;
//     } else {
//         sub = b - a;
//     }

//     if (sub * 2 === 2) {
//         console.log(-1);
//     } else if (a > sub * 2 || c > sub * 2) {
//         console.log(-1);
//     } else {
//         var spe1 = c - sub;
//         if (spe1 === 1) {
//             console.log(spe1);
//         } else {
//             var spe2 = sub + sub;
//             console.log(spe2);
//         }
//     }

// }

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});

function readline() {
    return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

    var t = Number(readline());
    for (var i = 1; i <= t; i++) {
        var a = Number(readline()),
            b = Number(readline()),
            c = Number(readline());
        var sub = 0;
        if (a > b) {
            sub = a - b;
        } else {
            sub = b - a;
        }

        if (sub * 2 === 2) {
            console.log(-1);
        } else if (a > sub * 2 || c > sub * 2) {
            console.log(-1);
        } else {
            var spe1 = c - sub;
            if (spe1 === 1) {
                console.log(spe1);
            } else {
                var spe2 = sub + sub;
                console.log(spe2);
            }
        }

    }

}

// Aujubillhi minassaitoanir rajim Vismillahir Rahmanir Rahim (Allah Hu Ackbar) Allah is Greatest.

// var t = Number(readline());
// for (var i = 0; i <= t; i++) {
//     var a = Number(readline()),
//         b = Number(readline()),
//         c = Number(readline());
//     var sub = 0;
//     if (a > b) {
//         sub = a - b;
//     } else {
//         sub = b - a;
//     }

//     if (sub * 2 === 2) {
//         console.log(-1);
//     } else if (a > sub * 2 || c > sub * 2) {
//         console.log(-1);
//     } else {
//         var spe1 = c - sub;
//         if (spe1 === 1) {
//             console.log(spe1);
//         } else {
//             var spe2 = sub + sub;
//             console.log(spe2);
//         }
//     }

// }

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
    console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main();
});

function readline() {
    return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

    var t = Number(readline());
    for (var i = 0; i <= t; i++) {
        var a = Number(readline()),
            b = Number(readline()),
            c = Number(readline());
        var sub = 0;
        if (a > b) {
            sub = a - b;
        } else {
            sub = b - a;
        }

        if (sub * 2 === 2) {
            console.log(-1);
        } else if (a > sub * 2 || c > sub * 2) {
            console.log(-1);
        } else {
            var spe1 = c - sub;
            if (spe1 === 1) {
                console.log(spe1);
            } else {
                var spe2 = sub + sub;
                console.log(spe2);
            }
        }

    }
}

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {

  let numOfTimes = readline();
  let line;
  print(readline())
  while (numOfTimes--) {
    line = readline();
    print(work(...line.split(" ")));
  }
}

function work(a,b,c){
const max= Math.max(a,b);
const half= 2*max - a-b;

if((max>2*half)||(c>2*half)) return -1

if(c>half){
    return c-half
}
else{
    return c+half;
}

}

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
  let numOfTimes = readline();
  let line;
  while (numOfTimes--) {
    line = readline();
    print(work(...line.split(" ")));
  }
}

function work(a,b,c){
const max= Math.max(a,b);
const half= 2*max - a-b;

if((max>2*half)||(c>2*half)) return -1

if(c>half){
    return c-half
}
else{
    return c+half;
}

}

const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [a1, b1, c1] = d.split(" ").map(Number);
  const diameter = Math.abs(a1 - b1);
  const circle = diameter * 2;

  if (circle < a1 || circle < b1) {
    console.log(-1);
  } else if (c1 >= circle) {
    console.log(-1);
  } else {
    const guess = c1 + diameter;
    if (guess > circle) {
      console.log(guess - circle);
    } else {
      console.log(guess);
    }
  }
  c++;
});

rl.on("close", () => {});

function main(input) {
    function readline() {
        return input.shift();
    }

    let lines = Number(readline());
    for(let i=0; i<lines; i++) {
        const data = readline().split(' ').map(Number)
        const [a, b, x] = data;

        const offset = Math.abs(a-b)
        const size = offset * 2;

        function getResult(){
            if([a, b, x].every(i => i < size)) {
                if(x > offset) {
                    return x - offset
                } else {
                    return x + offset
                }
            }
            return '-1';
        }
        console.log(getResult());
    }
}

////////////////////////
let inputString = '';
process.stdin.on('data', (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on('end', (_) => {
    inputString = inputString.trim().split('\n').map((string) => string.trim());

    main(inputString);
});

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

  var t=parseInt(readline())

while(t--){
    var array=readline().split(' ').map(x=>parseInt(x));
    var a=array[0];
    var b=array[1];
    var c=array[2]

    var distance=Math.abs(a-b);
    var n=distance*2;
    if(distance<=1){
        print('-1')
    }else if(n<=a || n<=b || n<c){
        print('-1')
    }
    else if((distance+c)>n){
        print(c-distance)
    }else{
        print(distance+c)
    }

}

}

function solve() {
   let [a, b, c] = readArray(Number);
   if (a > b) {
      const temp = a;
      a = b;
      b = temp;
   }
   const diff = b - a;
   if (!(a <= diff && b > diff)) {
      write(-1);
      return;
   }
   const ans1 = c + diff;
   const ans2 = c - diff;
   if (ans1 <= diff * 2 && ans1 > 0) {
      write(ans1);
      return;
   }
   if (ans2 <= diff * 2 && ans2 > 0) {
      write(ans2);
      return;
   }
   write(-1);
}

function init() {
   try {
      var T;
      T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1n;
   while(curN) {
      if (curN & 1n) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1n;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}


var x = +readline().split(' ')[1];

var s = Math.abs(readline().split(' ').map(Number).reduce(function (p, e) { return p + e; }, 0));

var t = 0;

while (s > 0) {
	t++;
	s -= x;
}

print(t);

print(function(n, x) {
	var sum = readline().split(' ').map(Number).reduce(function(a, b) {
		return a + b;
	});
	sum = Math.abs(sum);
	return Math.ceil(sum / x);
}.apply(0, readline().split(' ').map(Number)));

function sum(array){
	var result = 0;
	for(var i = 0; i < array.length; i++){
		result += +array[i];
	}
	return result;
}

var input = readline().split(" "), n = +input[0], x = +input[1], numbers = readline().split(" ").map(Number),
all = sum(numbers);

if(all == 0){
	write(0);
}
else{
	if(Math.abs(all) <= x){
		write(1);
	}
	else{
		write(Math.ceil(Math.abs(all)/x));
	}
}

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var foundNum = integers[0], max = integers[1];
	var cards = tokenizeIntegers(readline());
	var sum = 0;
	for (var i = 0; i < cards.length; ++i) {
		sum += cards[i];
	}
	sum = Math.abs(sum);
	var count = 0;
	while (sum > max) {
		sum -= max;
		count += 1;
	}
	if (sum > 0) {
		count += 1;
	}
	print(count);
}

main();

function solve(){
    var input = readline().split(" ");
    var n = parseInt(input[0]);
    var x = parseInt(input[1]);
    var a = readline().split(" ");
    var sum = 0;
    for(var i = 0; i < a.length; i++){
        sum += parseInt(a[i]);
    }
    sum = sum < 0 ? -sum : sum;
    var res = Math.floor((sum + x - 1)/x);
    print(res);
}
solve();

function main() {
  var nx = readline().split(' ');
  var line = readline().split(' ');
  var n = Number(nx[0]),
    x = Number(nx[1]),
    sum = 0;

  for (var i = 0; i < n; i++) {
    sum += Number(line[i]);
  }

  var changes = 0;

  while (sum > 0) {
    if (sum > x) {
      sum -= x;
      changes++;
    } else {
      sum = 0;
      changes++;
    }
  }

  while (sum < 0) {
    if (sum * -1 > x) {
      sum += x;
      changes++;
    } else {
      sum = 0;
      changes++;
    }
  }

  print(changes);
}

main();

function main(){
    var line = readline().split(' ');
    var n = parseInt(line[0]);
    var x = parseInt(line[1]);
    var sum = 0;
    readline().split(' ').forEach(function (v){
        sum += parseInt(v);
    });
    print(Math.ceil(Math.abs(sum)/x));
}
main();

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let n, x;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [n, x] = d.split(' ').map(Number);
    return;
  }

  const arr = d.split(' ').map(Number);
  const sum = Math.abs(arr.reduce((a, b) => a + b, 0));
  const ans = Math.ceil(sum / x);

  console.log(ans);
  c++;
});

/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces_401A
var gi = process.stdin;
gi.setEncoding('utf8');
var go = (x) => process.stdout.write(x);
function parseArray(line) { return line.split(' ').map(function (a) { return parseInt(a); }); }

let main = function(data){
	var lines = data.split("\n");
	var a = parseArray(lines[0]);
	var n = a[0], x = a[1];
	a = parseArray(lines[1]);
	var sum = 0;
	for (var k in a) {
		sum += a[k];
	}
	sum = Math.abs(sum);
	var ans = Math.floor(sum/x);
	if (sum%x != 0) { ans++; }
	go(ans + "");
	return 0;
}
gi.on("data", main);

var x = +readline().split(' ')[1];

var s = Math.abs(readline().split(' ').map(Number).reduce(function (p, e) { return p + e; }, 0));

var t = 0;

while (s > 0) {
	t++;
	s -= (x-1);
}

print(t);

function main(){
    var line = readline().split(' ');
    var n = parseInt(line[0]);
    var x = parseInt(line[1]);
    var sum = 0;
    readline().split(' ').forEach(function (v){
        sum += parseInt(v);
    });
    print(Math.ceil(sum/x));
}
main();

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let n, x;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [n, x] = d.split(' ').map(Number);
    return;
  }

  const arr = d.split(' ').map(Number);
  const sum = Math.abs(arr.reduce((a, b) => a + b, 0));
  const ans = Math.floor(sum / x) + sum % x;

  console.log(ans);
  c++;
});


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [x, y] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(x, y)
    }
    console.log(output.join('\n'))
// })()
})

function solve(x, y) {
    const ab = Math.floor(y / x)
    const b1r = y % x
// console.log('-', ab, b1r)
    if (!ab) {
        // y < x
        return x + y
    }
    const limit = Math.sqrt(ab)
    for (let i = 1; i <= limit; i++) {
        if (ab % i) continue
        // b = i or ab / i
        let b = i
        if (!(b1r % (b + 1))) {
            const r = b1r / (b + 1)
            const n = (y - r) / b
            // console.log('b1', b, n)
            if (r < x && r < y) return n
        }
        b = ab / i
        if (!(b1r % (b + 1))) {
            const r = b1r / (b + 1)
            const n = (y - r) / b
            // console.log('b2', b, n)
            if (r < x && r < y) return n
        }
        // console.log(i, ab)
    }
}

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const [x, y] = rna();

		let ans;
		if (x > y)
			ans = x + y;
		else
			ans = y - y%x/2;

		console.log(ans);
	}
}

'use strict';

function solve(x, y) {
  if (x === y) return x;else if (x > y) return x + y;else if (y % x === 0) return x;else return y - (x + y) / 2 % x;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      res.push(solve(n, m));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});

'use strict';

function solve(x, y) {
  if (x === y) return x;else if (x > y) return x + y;else if (y % x === 0) return x;else return (x + y) / 2;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      res.push(solve(n, m));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});

'use strict';

function solve(x, y) {
  if (x === y) return x;else if (x > y) return x + y;else return (x + y) / 2;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    let t1 = t;
    let params = [];
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      params.push([n, m]);
      res.push(solve(n, m));
    }
    if (t1 === 100000) {
      console.log(params[406].join(','));
      return;
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});

'use strict';

function solve(x, y) {
  if (x === y) return x;else if (x > y) return x + y;else return (x + y) / 2;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    let t1 = t;
    let params = [];
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      params.push([n, m]);
      res.push(solve(n, m));
    }
    if (t1 === 100000) {
      console.log(params[406]);
      return;
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});

'use strict';

function solve(n, m) {
  if (n === m) return n;else if (n > m) return n + m;else return (n + m) / 2;
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const [n, m] = (await read()).split(' ').map(Number);
      res.push(solve(n, m));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const str = lines[l++]
        const [w, q] = lines[l++].trim().split(' ').map(Number)
        const qs = lines.slice(l, l + q).map(str => str.trim().split(' ').map(Number))
        l += q
        output[i] = solve(str, w, qs)
    }
    console.log(output.join('\n'))
// })()
})

function solve(str, w, qs) {
    const n = str.length
    const rs = Array(n)
    // const trs = [] // 10^i % 9
    let temp = 0
    let ten = 1
    for (let i = str.length - 1; i >= 0; i--) {
        const x = +str[i]
        // temp += x * ten
        // ten *= 10
        temp = add(temp, mul(x, ten))
        rs[i] = temp
        // trs.push(ten)
        ten = mul(ten, 10)
    }
// console.log(rs)
    //
    const first = Array(9).fill(0)
        .map(() => [])
    for (let i = n - 1; i - w + 1 >= 0; i--) {
        const x = range(i - w + 1, i)
        // console.log(str.slice(i - w + 1, i + 1), x)
        // first[x] = i - w + 1
        first[x].unshift(i - w + 1)
    }
    // console.log(first)
    return qs.map(([l, r, k]) => {
        // v1 * vlr + v2 = k
        const vlr = range(l - 1, r - 1)
        let l1 = Infinity, l2 = Infinity
        for (let v1 = 0; v1 < 9; v1++) {
            if (first[v1].length) {
                const v2 = minus(k, mul(v1, vlr))
            // console.log(v1, v2)
                if (first[v2].length) {
                    let a = first[v1][0]
                    let b = first[v2][0]
                    if (v1 === v2) {
                        if (first[v1].length < 2) continue
                        b = first[v1][1]
                    }
                    if (a < l1) {
                        l1 = a
                        l2 = b
                    } else if (a === l1) {
                        if (b < l2) {
                            l2 = b
                        }
                    }
                }
            }
        }
        const ans = (l1 === Infinity || l2 === Infinity) ? [-1, -1] : [l1 + 1, l2 + 1]
        return ans.join(' ')
    }).join('\n')

    function range(l, r) {
        return minus(rs[l], r + 1 < n ? rs[r + 1] : 0)
    }
}
const MOD = 9
function minus(a, b) {
    return add(add(a, -b), MOD)
}
function add(a, b) {
    return (a + b) % 9
}
function mul(a, b) {
    return (a * b) % 9
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const rns = () => {
    return read().split(' ').filter(s => s !== '').map(Number);
  };
  const s = read();
  const [w, m] = rns();
  const pre = [];
  const mod = num => (num % 9 + 9) % 9;
  for (let i = 0; i < s.length; i++) {
    var _pre;
    pre[i] = mod(((_pre = pre[i - 1]) !== null && _pre !== void 0 ? _pre : 0) * 10 + Number(s[i]));
  }
  const query = (l, r) => {
    var _pre2;
    return mod(pre[r] - ((_pre2 = pre[l - 1]) !== null && _pre2 !== void 0 ? _pre2 : 0));
  };
  const v = [];
  for (let i = 0; i < s.length - w + 1; i++) {
    v[i] = query(i, i + w - 1);
  }
  const map = new Map();
  for (let i = 0; i < v.length; i++) {
    if (!map.has(v[i])) map.set(v[i], []);
    if (map.get(v[i]).length < 2) map.get(v[i]).push(i);
  }
  const res = [];
  for (let i = 0; i < m; i++) {
    const [l, r, k] = rns();
    const a = query(l - 1, r - 1);
    let ans = [-1, -1];
    const add = ([a, b]) => {
      if (ans[0] === -1 || ans[0] > a || ans[0] === a && ans[1] > b) {
        ans = [a, b];
      }
    };
    for (let j = 0; j < 9; j++) {
      if (!map.has(j)) continue;
      const t = mod(k - a * j);
      if (!map.has(t)) continue;
      if (j === t) {
        if (map.get(j).length < 2) continue;
        add(map.get(j));
      } else {
        add([map.get(j)[0], map.get(t)[0]]);
      }
    }
    res.push(ans.map(num => num !== -1 ? num + 1 : num).join(' '));
  }
  return res.join('\n');
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r\n?/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const rns = () => {
    return read().split(' ').filter(s => s !== '').map(Number);
  };
  const s = read();
  const [w, m] = rns();
  const pre = [];
  const mod = num => (num % 9 + 9) % 9;
  for (let i = 0; i < s.length; i++) {
    var _pre;
    pre[i] = mod(((_pre = pre[i - 1]) !== null && _pre !== void 0 ? _pre : 0) * 10 + Number(s[i]));
  }
  const query = (l, r) => {
    var _pre2;
    return mod(pre[r] - ((_pre2 = pre[l - 1]) !== null && _pre2 !== void 0 ? _pre2 : 0));
  };
  const v = [];
  for (let i = 0; i < s.length - w + 1; i++) {
    v[i] = query(i, i + w - 1);
  }
  const map = new Map();
  for (let i = 0; i < v.length; i++) {
    if (!map.has(v[i])) map.set(v[i], []);
    if (map.get(v[i]).length < 2) map.get(v[i]).push(i);
  }
  const res = [];
  for (let i = 0; i < m; i++) {
    const [l, r, k] = rns();
    const a = query(l - 1, r - 1);
    let ans = [-1, -1];
    const add = ([a, b]) => {
      if (a > b) [a, b] = [b, a];
      if (ans[0] === -1 || ans[0] > a || ans[0] === a && ans[1] > b) {
        ans = [a, b];
      }
    };
    for (let j = 0; j < 9; j++) {
      if (!map.has(j)) continue;
      const t = mod(k - a * j);
      if (!map.has(t)) continue;
      if (j === t) {
        if (map.get(j).length < 2) continue;
        add(map.get(j));
      } else {
        add([map.get(j)[0], map.get(t)[0]]);
      }
    }
    res.push(ans.map(num => num !== -1 ? num + 1 : num).join(' '));
  }
  return res.join('\n');
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r\n?/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();


/* TEST CASE
input
2
50 50
output
5.0000000000
input
4
50 20 20 10
output
39.2846263444
 */
function main() {
	var n = parseInt(readline());
	var p = new Array(n);
	var f = new Array(n);
	var splitted = readline().split(' ');
	var i, g = 1.0;

	for (i = 0; i < n; i++) {
		var Pi = parseFloat(splitted[i]) / 100.0;
		p[i] = Pi;
		f[i] = Pi
		g *= Pi;
	}

	var answer = g * n;
	var x = n;

	while (x++ < 300001) {
        var maxProb = 0;
        var id;
        for (i = 0; i < n; i++) {
        	var prob = p[i] * (1-f[i])/f[i];
            if (prob > maxProb) {
            	maxProb = prob;
                id = i;
            }
        }
        f[id] += p[id] * (1 - f[id]);
        answer += x * g * maxProb;
        g *= (1 + maxProb);
	}
	print(answer.toFixed(10));
}

main();

/* TEST CASE
input
2
50 50
output
5.0000000000
input
4
50 20 20 10
output
39.2846263444
 */
function main() {
	var n = parseInt(readline());
	var p = new Array(n);
	var f = new Array(n);
	var splitted = readline().split(' ');
	var i, g = 1.0;

	for (i = 0; i < n; i++) {
		var Pi = parseFloat(splitted[i]) / 100.0;
		p[i] = Pi;
		f[i] = Pi
		g *= Pi;
	}

	var answer = g * n;
	var x = n;

	while (x++ < 300001) {
        var maxProb = 0;
        var id;
        for (i = 0; i < n; i++) {
            if (p[i] * (1-f[i])/f[i] > maxProb) {
            	maxProb = p[i] * (1-f[i])/f[i];
                id = i;
            }
        }
        f[id] += p[id] * (1 - f[id]);
        answer += x * g * maxProb;
        g *= (1.0 + maxProb);
	}
	print(answer.toFixed(10));
}

main();

/* TEST CASE
input
2
50 50
output
5.0000000000
input
4
50 20 20 10
output
39.2846263444
 */
function main() {
	var n = parseInt(readline());
	var p = new Array(n);
	var f = new Array(n);
	var splitted = readline().split(' ');
	var i, g = 1.0;

	for (i = 0; i < n; i++) {
		var Pi = parseFloat(splitted[i]) / 100.0;
		p[i] = Pi;
		f[i] = Pi
		g *= Pi;
	}

	var answer = g * n;
	var x = n;

	while (x++ < 300001) {
        var tmp = 0;
        var id;
        for (i = 0; i < n; i++) {
            if (p[i] * (1-f[i])/f[i] + 1 > tmp) {
                tmp = p[i] * (1-f[i])/f[i] + 1;
                id = i;
            }
        }
        f[id] += p[id] * (1 - f[id]);
        answer += x * g * (tmp - 1);
        g *= tmp;
	}
	print(answer.toFixed(10));
}

main();


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    const result = [];
    const map = arr.reduce((obj, num) => {
      if (!obj[num]) {
        obj[num] = 1;
        result.push(num);
      }
      return obj;
    }, {});
    console.log(result.join(" "));
  }
}

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question("", function (n) {
  functions();
})

function functions() {
  rl.question("", function (n) {
    rl.question("", function (num) {
      var arr = num.split(' ');
      var l = [];
      for (var i = 0; i < n * 2; i++) {
        for (var j = 0; j < arr.length; j++) {
          var lhas = l.includes(arr[j])
          if (!lhas) {
            l.push(arr[j]);

          }
        }
      }
      console.log(l.join(' '));
      functions();
    });
  })
}
// rl.question('', function (o) {
//   rl.question('', function (n) {
//     rl.question('', function (a) {
//       rl.question('', function (b) {
//         var s = 0;
//         var sa = a.split(' ');
//         var sb = b.split(' ');
//         // console.log(n, newA, s, sa, sb)
//         for (var i = 0; i < n; i++) {
//           var newA = [];
//           var ai = sa[i] - Math.min.apply(Math, sa)
//           var bi = sb[i] - Math.min.apply(Math, sb)
//           newA.push(ai);
//           newA.push(bi);
//           s += Math.max.apply(Math, newA);
//         }
//         console.log(s)
//         functions();
//       })
//     })
//   })
// })

//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;

  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var t = nextInt();
	var output = [];
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray();
		var out = [];
		for(var j = 0; j < list.length; j++){
			if(out.indexOf(list[j]) == -1){
				out.push(list[j]);
			}
		}
		output[i] = myconv(out,8);
	}
	myout(myconv(output,9));
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
});

process.stdin.on('end', () => {
  main(stdinInput);
});

function main(data) {
	data = data.split('\n');
	const testCases = data[0] * 2;
	let i = 1;
	while (i <= testCases) {
    let n = data[i] * 1;
    let a = data[i + 1].trim().split(' ');
    let str = a[0]
    let obj = {};
    obj[str] = true;
    for (let i = 1; i < a.length; i += 1) {
      if (obj[a[i]]) {}
      else {
        obj[a[i]] = true;
        str += ' ' + a[i];
      }
    }
    console.log(str);
    i += 2;
	}
}

const processData = (lines) => {
  let num = 0;
  const n = +lines[num++];
  for (let i = 0; i < n; i++) {
    num++;
    const line = lines[num++].split(" ").map((x) => +x); //转数字
    const map = new Map();
    const res = [];
    line.forEach((element) => {
      if (map.get(element) === undefined) {
        map.set(element, 1);
        res.push(element);
      }
    });
    console.log(res.join(" "));
  }
};

let i = "";
process.stdin.on("data", (c) => (i += c));
process.stdin.on("end", () => {
  const { EOL } = require("os"); //获取换行符
  const lines = i.split(EOL);
  processData(lines);
});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
	const testcases = parseInt(readline());
	for (let i = 0; i < testcases; i++) {
		const l = parseInt(readline());
		const merged = readline().split(' ').map(i => parseInt(i))
		const unique = Array.from(new Set([...merged]))
		console.log(unique.join(' '))
	}
}

const processData = (lines) => {
    let acc = 0
    const n = +lines[acc++]
    for (let i=0; i<n; i++) {
        acc++
        const p = lines[acc++].split(' ').map(x => +x)

        const map = {}
        const res = []
        for (const t of p) {
            if (!map[t]) {
                map[t] = 1
                res.push(t)
            }
        }
        console.log(res.join(' '))
    }

}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    processData(lines)
})

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

  var tc = parseInt(readline());
  while (tc--) {
    var n = parseInt(readline());
    var ar = readline().split(' ').map(x => parseInt(x));
    var unique = Array.from(new Set([...ar]));
    print(unique.join(' '));
  }

}

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function readLine() {
  return inputString[currentLine++];
}

/******** Main function*************/

function main() {
  var t = +readLine();

  for (var i = 0; i < t; i++) {
    var n = +readLine();
    var arr = readLine().split(" ").map(Number);
    const uni = [...new Set(arr)];
    console.log(uni.join(" "));
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
5
2
1 1 2 2
4
1 3 1 4 3 4 2 2
5
1 2 1 2 3 4 3 5 4 5
3
1 2 3 1 2 3
4
2 3 2 4 1 3 4 1

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

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

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve(r);
    }

}

function solve(index) {
    let n = Number(readline())
    let a = readline().split(" ").map(Number);

    let output = new Set([...a]);

    console.log([...output].join(" "));

}

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

var lineCount = 0
var testCount = 0
var outputStr = ''

rl.on('line', (input) => {
    if (lineCount == 0) {
        // first line
        testCount = parseInt(input)
    }
    else if(lineCount%2==1){
        //do nothing?
    }
    else if (lineCount >= 2*testCount) {
        outputStr += compute(input) + '\n'
        console.log(outputStr)
        rl.close()
    }
    else {
        // data
        outputStr += compute(input) + '\n'
    }
    lineCount++
});

function compute(str) {
    var list = str.split(' ')

    var tmplist = []

    var resultstr = ''

    for(var item of list){
        if(tmplist[item]){
            // already exist
            continue
        }
        resultstr += `${item} `
        tmplist[item] = true
    }
    return resultstr
}

function solve() {
   var n = Number(read());
   var arr = readArray(Number);
   var ans = [];
   var s = {};
   for (var i = 0; i < (n << 1); i++) {
      if (s[arr[i]]) {
         ans.push(arr[i]);
      } else {
         s[arr[i]] = true;
      }
   }
   write(ans.join(' '));
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question("", function (n) {
  functions();
})

function functions() {
  rl.question("", function (n) {
    rl.question("", function (num) {
      var arr = num.split(' ');
      var l = [];
      for (var i = 0; i < n * 2; i++) {
        for (var j = 0; j < arr.length; j++) {
          var lhas = l.includes(arr[j])
          if (!lhas) {
            l.push(arr[j]);
          }
        }
      }
      console.log(l);
      functions();
    });
  })
}
// rl.question('', function (o) {
//   rl.question('', function (n) {
//     rl.question('', function (a) {
//       rl.question('', function (b) {
//         var s = 0;
//         var sa = a.split(' ');
//         var sb = b.split(' ');
//         // console.log(n, newA, s, sa, sb)
//         for (var i = 0; i < n; i++) {
//           var newA = [];
//           var ai = sa[i] - Math.min.apply(Math, sa)
//           var bi = sb[i] - Math.min.apply(Math, sb)
//           newA.push(ai);
//           newA.push(bi);
//           s += Math.max.apply(Math, newA);
//         }
//         console.log(s)
//         functions();
//       })
//     })
//   })
// })