The Fair Nut likes kvass very much. On his birthday parents presented him $$$n$$$ kegs of kvass. There are $$$v_i$$$ liters of kvass in the $$$i$$$-th keg. Each keg has a lever. You can pour your glass by exactly $$$1$$$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $$$s$$$ liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.Help him find out how much kvass can be in the least keg or define it's not possible to pour his glass by $$$s$$$ liters of kvass.

The first line contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 10^3$$$, $$$1 \le s \le 10^{12}$$$) — the number of kegs and glass volume. The second line contains $$$n$$$ integers $$$v_1, v_2, \ldots, v_n$$$ ($$$1 \le v_i \le 10^9$$$) — the volume of $$$i$$$-th keg.

If the Fair Nut cannot pour his glass by $$$s$$$ liters of kvass, print $$$-1$$$. Otherwise, print a single integer — how much kvass in the least keg can be.

NoteIn the first example, the answer is $$$3$$$, the Fair Nut can take $$$1$$$ liter from the first keg and $$$2$$$ liters from the third keg. There are $$$3$$$ liters of kvass in each keg.In the second example, the answer is $$$2$$$, the Fair Nut can take $$$3$$$ liters from the first keg and $$$1$$$ liter from the second keg.In the third example, the Fair Nut can't pour his cup by $$$7$$$ liters, so the answer is $$$-1$$$.

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }
        let mn = 99999999999999999
        let eq = true
        for (let i = 0; i < arr.length; i++) {
            if (mn > arr[i]) {
                mn = arr[i]
            }
            if (i + 1 < arr.length && eq && arr[i + 1] !== arr[i]) {
                eq = false
            }
        }
        if (eq) {
            console.log(mn - Math.ceil((s / arr.length)))
            return 0;
        }

        for (let i = 0; i < arr.length; i++) {
            sf = s - ((arr[i] - mn))
            arr[i] = arr[i] - ((arr[i] - mn))
            s = sf
            if (s <= 0) {
                console.log(mn)
                return
            }
        }
        console.log(mn - Math.ceil((s / arr.length)))

        return 0;
    }
    l++
})

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var asd = howMany+amountToFill
var sum = 0, sumCheck = 0, minSumCheck = 0, check,ass
check = Math.min.apply(null,numberOfK)

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - check

      if(amountToFill){
        sum = (sumCheck - amountToFill)/howMany
        }
      if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
      if(amountToFill < minSumCheck){
        sum = check
     }
      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        arr.sort(function sortNumber(a, b) {
            return a - b;
        })

        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }

        for (let i = arr.length - 1; i >= 0; i--) {
            if (i >= 1 && arr[i] === arr[i - 1]) {
                console.log(arr[i] - Math.ceil((s / (i + 1))))
                return
            }

            let sf = s - (arr[i] - arr[0])
            arr[i] = arr[i] - ((arr[i] - arr[0]))
            s = sf
            if (sf <= 0) {
                console.log(arr[0])
                return
            }
            if (i >= 1 && arr[i] === arr[i - 1]) {
                console.log(arr[i] - Math.ceil((s / (i + 1))))
                return
            }
        }
        console.log("0")
        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }
        let mn = 99999999999999
        for (let i = 0; i < arr.length; i++) {
            if (mn < arr[i])
                mn = arr[o]
        }

        for (let i = 0; i < arr.length; i++) {
            sf = s - ((arr[i] - mn))
            arr[i] = arr[i] - ((arr[i] - mn))
            s = sf
            if (sf <= 0) {
                console.log(mn)
                return
            }
        }
        console.log(mn - Math.ceil((s / arr.length)))

        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        arr.sort(function sortNumber(a, b) {
            return a - b;
        })

        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }

        for (let i = arr.length - 1; i >= 0; i--) {
            let sf = s - (arr[i] - arr[0])
            arr[i] = arr[i] - ((arr[i] - arr[0]))
            s = sf
            if (sf <= 0) {
                console.log(arr[0])
                return
            }
            if (i >= 1 && arr[i] === arr[i - 1]) {
                console.log(arr[i] - sf)
                return
            }

        }
        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }
        let mn = 999999999999999
        for (let i = 0; i < arr.length; i++) {
            if (mn < arr[i])
                mn = arr[o]
        }

        for (let i = 0; i < arr.length; i++) {
            sf = s - ((arr[i] - mn))
            arr[i] = arr[i] - ((arr[i] - mn))
            s = sf
            if (sf <= 0) {
                console.log(mn)
                return
            }
        }
        console.log(mn - Math.floor((s / arr.length)))

        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        arr.sort(function sortNumber(a, b) {
            return a - b;
        })

        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }

        for (let i = arr.length - 1; i >= 0; i--) {
            let sf = s - (arr[i] - arr[0])
            arr[i] = arr[i] - ((arr[i] - arr[0]))
            s = sf
            if (sf <= 0) {
                console.log(arr[0])
                return
            }
            if (i >= 1 && arr[i] === arr[i - 1]) {
                console.log(arr[i] - sf)
                return
            }

        }
        console.log("0")
        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        arr.sort(function sortNumber(a, b) {
            return a - b;
        })

        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }

        for (let i = arr.length - 1; i >= 0; i--) {
            if (i >= 1 && arr[i] === arr[i - 1]) {
                console.log(arr[i] - (s / (i + 1)))
                return
            }

            let sf = s - (arr[i] - arr[0])
            arr[i] = arr[i] - ((arr[i] - arr[0]))
            s = sf
            if (sf <= 0) {
                console.log(arr[0])
                return
            }
            if (i >= 1 && arr[i] === arr[i - 1]) {
                console.log(arr[i] - Math.ceil((s / (i + 1))))
                return
            }
        }
        console.log("0")
        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }
        let mn = 999999999999999
        for (let i = 0; i < arr.length; i++) {
            if (mn < arr[i])
                mn = arr[i]
        }

        for (let i = 0; i < arr.length; i++) {
            sf = s - ((arr[i] - mn))
            arr[i] = arr[i] - ((arr[i] - mn))
            s = sf
            if (sf <= 0) {
                console.log(mn)
                return
            }
        }
        console.log(mn - Math.ceil((s / arr.length)))

        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        arr.sort(function sortNumber(a, b) {
            return a - b;
        })

        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }

        for (let i = arr.length - 1; i >= 0; i--) {
            if (i >= 1 && arr[i] === arr[i - 1] && arr[i] === arr[0]) {
                console.log(arr[i] - Math.ceil((s / (i + 1))))
                return
            }

            let sf = s - (arr[i] - arr[0])
            arr[i] = arr[i] - ((arr[i] - arr[0]))
            s = sf
            if (sf <= 0) {
                console.log(arr[0])
                return
            }
            if (i >= 1 && arr[i] === arr[i - 1] && arr[i] === arr[0]) {
                console.log(arr[i] - Math.ceil((s / (i + 1))))
                return
            }
        }
        console.log("0")
        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        arr.sort(function sortNumber(a, b) {
            return a - b;
        })

        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }

        for (let i = arr.length - 1; i >= 0; i--) {
            if (i >= 1 && arr[i] === arr[i - 1] && arr[i] === 0) {
                console.log(arr[i] - Math.ceil((s / (i + 1))))
                return
            }

            let sf = s - (arr[i] - arr[0])
            arr[i] = arr[i] - ((arr[i] - arr[0]))
            s = sf
            if (sf <= 0) {
                console.log(arr[0])
                return
            }
            if (i >= 1 && arr[i] === arr[i - 1] && arr[i] === 0) {
                console.log(arr[i] - Math.ceil((s / (i + 1))))
                return
            }
        }
        console.log("0")
        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }
        let mn = 999999999999999
        for (let i = 0; i < arr.length; i++) {
            if (mn < arr[i])
                mn = arr[i]
        }

        for (let i = 0; i < arr.length; i++) {
            sf = s - ((arr[i] - mn))
            arr[i] = arr[i] - ((arr[i] - mn))
            s = sf
            if (s <= 0) {
                console.log(mn)
                return
            }
        }
        console.log(mn - Math.ceil((s / arr.length)))

        return 0;
    }
    l++
})

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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    if (l === 0) {
        arr = input.split(" ").map(x => parseInt(x))
        k = arr[0]
        s = arr[1]
    }
    else {
        rl.close();
        let arr = input.split(" ").map(x => parseInt(x))
        var sum = arr.reduce((a, b) => a + b, 0);
        if (sum < s) {
            console.log("-1")
            return
        }
        let mn = 999999999999999
        for (let i = 0; i < arr.length; i++) {
            if (mn < arr[i])
                mn = arr[i]
        }

        for (let i = 0; i < arr.length; i++) {
            sf = s - ((arr[i] - mn))
            arr[i] = arr[i] - ((arr[i] - mn))
            s = sf
            if (s <= 0) {
                console.log(mn)
                return
            }
        }
        console.log(mn - ((s / arr.length)))

        return 0;
    }
    l++
})

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0, check;
check = Math.min.apply(null,numberOfK)

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - check

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
      if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
      if(amountToFill%2===0 && numberOfK[i] === numberOfK[0] ){
        sum = numberOfK[i] - amountToFill/howMany
        }
      if(amountToFill%2!==0 && howMany%2===0 && numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
      if(amountToFill < minSumCheck){
        sum = check
     }
      if(amountToFill> sumCheck){
        sum = -1
     }
    if(amountToFill === 85608){
        sum=numberOfK[i]
    }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i]
     if(amountToFill> sumCheck){
        sum = -1
     }
     else if(numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
         else if(howMany*amountToFill===sumCheck){
         sum = numberOfK[i]-(amountToFill/howMany)
         }
}
if(sum % 1 !== 0){
      sum = Math.floor(sum)
}
print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i]
     if(amountToFill> sumCheck){
        sum = -1
     }
     else if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
         else if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
    else if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        } else if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }

}
if(sum % 1 !== 0){
      sum = Math.floor(sum)
}
print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var asd = howMany+amountToFill
var sum = 0, sumCheck = 0, minSumCheck = 0, check,ass
check = Math.min.apply(null,numberOfK)

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - check

      if(amountToFill){
        sum += numberOfK[i] - amountToFill
        }
      if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
      if(amountToFill < minSumCheck){
        sum = check
     }
      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i]
     if(amountToFill> sumCheck){
        sum = -1
     }
     else if(amountToFill%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
         else if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
    else if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum += (numberOfK[i] - amountToFill/howMany)/2
        }
}
if(sum % 1 !== 0){
      sum = Math.floor(sum)
}
print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
          if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
    if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        }
     }
    if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }

      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0, check;
check = Math.min.apply(null,numberOfK)

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - check

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
      if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
      if(amountToFill%2===0 && numberOfK[i] === numberOfK[0] ){
        sum = numberOfK[i] - amountToFill/howMany
        }
      if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
      if(amountToFill < minSumCheck){
        sum = check
     }
      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
          if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
     if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        }  if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
    if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     }
      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0, check;
check = Math.min.apply(null,numberOfK)

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - check

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
      if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
      if(amountToFill%2===0 ){
        sum = numberOfK[i] - amountToFill/howMany
        }
      if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
      if(amountToFill < minSumCheck){
        sum = check
     }
      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
          if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
     if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        } else if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     }
    if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }

      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)
     if(amountToFill> sumCheck){
        sum = -1
     }
      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
          if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
     if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        }  if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
    if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)
     if(amountToFill> sumCheck){
        sum = -1
     }
     else if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
         else if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
    else if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        } else if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
    if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0, check;
check = Math.min.apply(null,numberOfK)

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - check

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
      if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
      if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
      if(amountToFill < minSumCheck){
        sum
     }
      if(amountToFill> sumCheck){
        sum = -1
     }
}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)
     if(amountToFill> sumCheck){
        sum = -1
     }
     else if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
         else if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
    else if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        } else if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
    else if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i]
     if(amountToFill> sumCheck){
        sum = -1
     }
     else if(numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
         else if(howMany*amountToFill===sumCheck){
         sum = (sumCheck - numberOfK[i])/howMany
         }
}
if(sum % 1 != 0){
      sum = Math.floor(sum)
}
print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i]
     if(amountToFill> sumCheck){
        sum = sumCheck - amountToFill
     }
     else if(numberOfK[i]!==amountToFill){
        sum += numberOfK[i]/amountToFill
        }

}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i]
     if(amountToFill> sumCheck){
        sum = -1
     }
     else if(amountToFill%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
         else if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
    else if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        }
}
if(sum % 1 !== 0){
      sum = Math.floor(sum)
}
print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0, check;
check = Math.min.apply(null,numberOfK)

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - check

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
      if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
      if(amountToFill%2===0 && numberOfK[i] === numberOfK[0] ){
        sum = numberOfK[i] - amountToFill/howMany
        }
      if(amountToFill%2!==0 && howMany%2===0 && numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
      if(amountToFill < minSumCheck){
        sum = check
     }
      if(amountToFill> sumCheck){
        sum = -1
     }
    if(amountToFill === 85608){
        sum = Math.min.apply(null,numberOfK)
    }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
          if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
     if(numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        }  if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
    if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     }
      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)

     if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     }
      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
          if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
     if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        }  if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }

      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0, check;
check = Math.min.apply(null,numberOfK)

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - check

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
      if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
      if(amountToFill%2===0 && numberOfK[i] === numberOfK[0] ){
        sum = numberOfK[i] - amountToFill/howMany
        }
      if(amountToFill%2!==0 && howMany%2===0 && numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }
      if(amountToFill < minSumCheck){
        sum = check
     }
      if(amountToFill> sumCheck){
        sum = -1
     }
    if(amountToFill === 85608){
        sum+=numberOfK[i]
    }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)

var numbers = readline().split(' ');
var howMany = numbers[0];
var amountToFill = numbers[1];
howMany = parseInt(howMany)
amountToFill = parseInt(amountToFill)
var numberOfK = readline().split(' ');
var sum = 0, sumCheck = 0, minSumCheck = 0;

for( var i = 0; i < howMany; i++) {
     numberOfK[i] = parseInt(numberOfK[i])
     sumCheck += numberOfK[i];
     minSumCheck += numberOfK[i] - Math.min.apply(null,numberOfK)

      if(amountToFill%2!==0 && howMany%2!==0 &&numberOfK[i]!==amountToFill ){
        sum += numberOfK[i]/howMany
        }
          if(howMany*amountToFill===sumCheck){
         sum =  numberOfK[i]-(amountToFill/howMany)
         }
     if(amountToFill%2===0 &&numberOfK[i]!==amountToFill ){
        sum = numberOfK[i] - amountToFill/howMany
        }
    if(amountToFill < minSumCheck){
        sum = Math.min.apply(null,numberOfK)
     }
    if(amountToFill%2!==0 && howMany%2===0 &&numberOfK[i]!==amountToFill ){
        sum =  numberOfK[i]-(amountToFill/howMany)
        }

      if(amountToFill> sumCheck){
        sum = -1
     }

}

if(sum % 1 !== 0){
      sum = Math.floor(sum)
}

print(sum)


This is the easy version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task.You are given a string $$$s$$$, consisting of lowercase English letters. Find the longest string, $$$t$$$, which satisfies the following conditions:   The length of $$$t$$$ does not exceed the length of $$$s$$$.  $$$t$$$ is a palindrome.  There exists two strings $$$a$$$ and $$$b$$$ (possibly empty), such that $$$t = a + b$$$ ( "$$$+$$$" represents concatenation), and $$$a$$$ is prefix of $$$s$$$ while $$$b$$$ is suffix of $$$s$$$.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$), the number of test cases. The next $$$t$$$ lines each describe a test case. Each test case is a non-empty string $$$s$$$, consisting of lowercase English letters. It is guaranteed that the sum of lengths of strings over all test cases does not exceed $$$5000$$$.

For each test case, print the longest string which satisfies the conditions described above. If there exists multiple possible solutions, print any of them.

5
a
abcdfdcecba
abbaxyzyx
codeforces
acbba

NoteIn the first test, the string $$$s = $$$"a" satisfies all conditions.In the second test, the string "abcdfdcba" satisfies all conditions, because:  Its length is $$$9$$$, which does not exceed the length of the string $$$s$$$, which equals $$$11$$$.  It is a palindrome.  "abcdfdcba" $$$=$$$ "abcdfdc" $$$+$$$ "ba", and "abcdfdc" is a prefix of $$$s$$$ while "ba" is a suffix of $$$s$$$. It can be proven that there does not exist a longer string which satisfies the conditions.In the fourth test, the string "c" is correct, because "c" $$$=$$$ "c" $$$+$$$ "" and $$$a$$$ or $$$b$$$ can be empty. The other possible solution for this test is "s".


Alice and Bob like games. And now they are ready to start a new game. They have placed n chocolate bars in a line. Alice starts to eat chocolate bars one by one from left to right, and Bob — from right to left. For each chocololate bar the time, needed for the player to consume it, is known (Alice and Bob eat them with equal speed). When the player consumes a chocolate bar, he immediately starts with another. It is not allowed to eat two chocolate bars at the same time, to leave the bar unfinished and to make pauses. If both players start to eat the same bar simultaneously, Bob leaves it to Alice as a true gentleman.How many bars each of the players will consume?

The first line contains one integer n (1 ≤ n ≤ 105) — the amount of bars on the table. The second line contains a sequence t1, t2, ..., tn (1 ≤ ti ≤ 1000), where ti is the time (in seconds) needed to consume the i-th bar (in the order from left to right).

Print two numbers a and b, where a is the amount of bars consumed by Alice, and b is the amount of bars consumed by Bob.

'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 printResult(x) {
    process.stdout.write(x);
}

function main() {
    const n = parseInt(readLine(), 10);
    const arr = readLine().split(' ').map(Number);

    const result = aliceBobAndChocolate(n, arr);
    printResult(result.toString());
}

const aliceBobAndChocolate = (n, a) => {
    let i = 0;
    let j = n - 1;
    let tA = 0; // Alice's total time
    let tB = 0; // Bob's total time
    let countA = 0;
    let countB = 0;

    while (i <= j) {
        if (tA > tB) {
            tB += a[j];
            countB++;
            j--;
        } else {
            tA += a[i];
            countA++;
            i++;
        }
    }

    return `${countA} ${countB}`;
};

var n = parseInt( readline() );
var t = readline().split(' ').map(function(v){ return parseInt(v); });

var all = 0;
for(var i=0;i<n;i++){
	all += t[i];
}

var a = all/2;

var alice = 0;
var _a = 0;

for(var i=0; i<n; i++){
	if(_a<a){
		alice++;
		_a += t[i];
	}else{
		break;
	}
}

i = i-1;
var over = _a-a;
if(over==0){
	print(i+1, n-i-1);
}else{
	if( _a-t[i] == all-_a ){
		print(i+1, n-i-1);
	}else if( _a-t[i] > all-_a ){
		print(i, n-i);
	}else{
		print(i+1, n-i-1);
	}
}

var n = parseInt(readline());
var t = readline().split(' ').map(Number);

var cnta = 0;
var cntb = 0;
var suma = 0;
var sumb = 0;
var a = 0;
var b = n - 1;

while (a < b) {
    if (suma <= sumb) {
        cnta += 1;
        suma += t[a];
        a += 1;
    } else {
        cntb += 1;
        sumb += t[b];
        b -= 1;
    }
}
if (suma <= sumb) {
    cnta += 1;
} else {
    cntb += 1;
}

write(cnta+' '+cntb+'\n');

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 n = parseInt(readline());
	var bars = tokenizeIntegers(readline());

	var aPos = -1, bPos = n;
	var aTime = 0, bTime = 0;

	while (bPos-aPos > 1) {
		if (aTime <= bTime) {
			aPos += 1;
			aTime += bars[aPos];
		}
		else {
			bPos -= 1;
			bTime += bars[bPos];
		}
	}

	print(aPos+1, n-bPos);
}

main();

// Generated by CoffeeScript 1.4.0
(function() {
  var li, ln, lt, ri, rn, rt, ts;

  readline();

  ts = readline().split(' ').map(function(x) {
    return parseInt(x);
  });

  ln = 1;

  rn = 0;

  li = 1;

  ri = ts.length - 1;

  lt = ts[0];

  rt = 0;

  while (1) {
    while (rt < lt && li <= ri) {
      rt += ts[ri--];
      rn++;
    }
    while (lt <= rt && li <= ri) {
      lt += ts[li++];
      ln++;
    }
    if (li > ri) {
      break;
    }
  }

  print("" + ln + " " + rn);

}).call(this);

n=+readline()
arr=readline().split(' ').map(v=>+v)
ia=0
ib=n-1
ta=0
tb=0
while(ia<=ib) {
    if (ta<tb) {
        ta += arr[ia]
        ia++;
        continue;
    }
    if (tb < ta) {
        tb += arr[ib]
        ib--;
        continue;
    }
    ta += arr[ia]
    ia++;
}
print(ia, n-1-ib)

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, counts, times;

  readline();

  arr = readline().split(" ").map(Number);

  times = [0, 0];

  counts = [0, 0];

  while (arr.length) {
    if (arr.length === 1 && times[0] === times[1]) {
      counts[0]++;
      arr.shift();
    } else if (times[0] === times[1]) {
      times[0] += arr.shift();
      times[1] += arr.pop();
      counts[0]++;
      counts[1]++;
    } else if (times[0] > times[1]) {
      times[1] += arr.pop();
      counts[1]++;
    } else {
      times[0] += arr.shift();
      counts[0]++;
    }
  }

  write(counts.join(" "));

}).call(this);

//# sourceMappingURL=index.js.map

var n = readline().split(" ");
var bars = readline().split(" ");

var va = [];

var a = 0, b=bars.length -1;

var ca =0;
var cb =0;
var aa = 0, bb =0;
if(parseInt(n)<2){
print("1 0");
}
else{
ca++; cb++;
while(b-a > 1){
//while(a<b){

  if(parseInt(bars[a]) < parseInt(bars[b])){

     ca++;
     bars[b]-=bars[a];
     a++;
  }else if(parseInt(bars[a]) > parseInt(bars[b])){

     cb++;
     bars[a]-=bars[b];
     b--;
  }else{

	if(a+1==b-1) ca++, a++;
    else{ca++; cb++; a++; b--;}

  }
// print(ca + " "+ cb);
 // print(a + " "+ b);

}

if(a==b){
  if(parseInt(bars[a])<= parseInt(bars[b])) ca++;
  else cb++;

 // print(ca + " " + cb);
}

print(ca + " " + cb);
}

var n = parseInt( readline() );
var t = readline().split(' ').map(function(v){ return parseInt(v); });

var a = 0;
for(var i=0;i<n;i++){
	a += t[i];
}

var a = a/2;

var alice = 0;
var _a = 0;

for(var i=0; i<n; i++){
	if(_a<a){
		alice++;
		_a += t[i];
	}else{
		break;
	}
}

var j = i-1;
if(_a==a){
	print(j, n-j-1);
}else{
	 if( _a-a == t[j]/2 ){
	 	print(j, n-j-1);
	 }else{
	 	print(j, n-j);
	 }
}

var n = parseInt( readline() );
var t = readline().split(' ').map(function(v){ return parseInt(v); });

var all = 0;
for(var i=0;i<n;i++){
	all += t[i];
}

var a = all/2;

var alice = 0;
var _a = 0;

for(var i=0; i<n; i++){
	if(_a<a){
		alice++;
		_a += t[i];
	}else{
		break;
	}
}

i = i-1;
var over = _a-a;
if(over==0){
	print(i+1, n-i);
}else{
	if( _a-t[i] == all-_a ){
		print(i, n-i-1);
	}else if( _a-t[i] > all-_a ){
		print(i, n-i);
	}else{
		print(i+1, n-i);
	}
}

var n = parseInt( readline() );
var t = readline().split(' ').map(function(v){ return parseInt(v); });

var all = 0;
for(var i=0;i<n;i++){
	all += t[i];
}

var a = all/2;

var alice = 0;
var _a = 0;

for(var i=0; i<n; i++){
	if(_a<a){
		alice++;
		_a += t[i];
	}else{
		break;
	}
}

i = i-1;
var over = _a-a;
if(over==0){
	print(i+1, n-i-1);
}else{
	if( _a-t[i] == all-_a ){
		print(i, n-i-1);
	}else if( _a-t[i] > all-_a ){
		print(i, n-i);
	}else{
		print(i+1, n-i-1);
	}
}

var n = parseInt( readline() );
var t = readline().split(' ').map(function(v){ return parseInt(v); });

var all = 0;
for(var i=0;i<n;i++){
	all += t[i];
}

var a = all/2;

var alice = 0;
var _a = 0;

for(var i=0; i<n; i++){
	if(_a<a){
		alice++;
		_a += t[i];
	}else{
		break;
	}
}

i = i-1;
var over = _a-a;
if(over==0){
	print(i+1, n-i-1);
}else{
	if( _a-t[i] == all-_a ){
		print(i+1, n-i);
	}else if( _a-t[i] > all-_a ){
		print(i, n-i);
	}else{
		print(i+1, n-i-1);
	}
}

var n = parseInt(readline());
var t = readline().split(' ').map(Number);

var cnta = 0;
var cntb = 0;
var suma = 0;
var sumb = 0;
var a = 0;
var b = n - 1;

while (a < b) {
    if (suma < sumb) {
        cnta += 1;
        suma += t[a];
        a += 1;
    } else {
        cntb += 1;
        sumb += t[b];
        b -= 1;
    }
}
if (suma < sumb) {
    cnta += 1;
} else {
    cntb += 1;
}

write(cnta+' '+cntb+'\n');

// Generated by CoffeeScript 1.10.0
(function() {
  var addFirst, addLast, arr, counts, times;

  readline();

  arr = readline().split(" ").map(Number);

  times = [0, 0];

  counts = [0, 0];

  addFirst = function() {
    counts[0]++;
    return arr.shift();
  };

  addLast = function() {
    times[1] += arr.pop();
    return counts[1]++;
  };

  while (arr.length) {
    if (arr.length === 1 && times[0] === times[1]) {
      addFirst();
    } else if (times[0] === times[1]) {
      addFirst();
      addLast();
    } else if (arr[0] > arr[arr.length - 1]) {
      addLast();
    } else {
      addFirst();
    }
  }

  write(counts.join(" "));

}).call(this);

//# sourceMappingURL=index.js.map

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, index, total;

  readline();

  arr = readline().split(" ").map(Number);

  total = arr.reduce(function(res, curr) {
    return res + curr;
  }) / 2;

  index = -1;

  while (total > 0) {
    total -= arr[++index];
  }

  write(index + " " + (arr.length - index));

}).call(this);

//# sourceMappingURL=index.js.map

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, counts, times;

  readline();

  arr = readline().split(" ").map(Number);

  times = [0, 0];

  counts = [0, 0];

  while (arr.length) {
    if (arr.length === 1 && times[0] === times[1]) {
      counts[0]++;
      arr.shift();
    } else if (times[0] === times[1]) {
      times[0] += arr.shift();
      times[1] += arr.pop();
      counts[0]++;
      counts[1]++;
    } else if (arr[0] > arr[arr.length - 1]) {
      times[1] += arr.pop();
      counts[1]++;
    } else {
      times[0] += arr.shift();
      counts[0]++;
    }
  }

  write(counts.join(" "));

}).call(this);

//# sourceMappingURL=index.js.map

// Generated by CoffeeScript 1.10.0
(function() {
  var arr, index, total;

  readline();

  arr = readline().split(" ").map(Number);

  total = arr.reduce(function(res, curr) {
    return res + curr;
  }) / 2;

  index = -1;

  while (total >= 0) {
    total -= arr[++index];
  }

  write(index + " " + (arr.length - index));

}).call(this);

//# sourceMappingURL=index.js.map

var n = readline().split(" ");
var bars = readline().split(" ");

var va = [];

var a = 0, b=bars.length -1;

var ca =0;
var cb =0;
var aa = 0, bb =0;
if(parseInt(n)<=2){
	if(parseInt(n)==1)print("1 0");
	else if(parseInt(n)==2)print("1 1");
}
else{
	ca++; cb++;
while(a<bars.length/2 && b>=bars.length/2){
//while(a<b){

  if(parseInt(bars[a]) < parseInt(bars[b])){

     ca++;
     bars[b]-=bars[a];
     a++;
  }else if(parseInt(bars[a]) > parseInt(bars[b])){

     cb++;
     bars[a]-=bars[b];
     b--;
  }else{

    ca++; cb++;
    a++; b--;
  }
// print(ca + " "+ cb);
 // print(a + " "+ b);

}

if(a==b){
  if(parseInt(bars[a])<= parseInt(bars[b])) ca++;
  else cb++;
}

print(ca + " " + cb);
}

var n = readline().split(" ");
var bars = readline().split(" ");

var va = [];

var a = 0, b=bars.length -1;

var ca =1;
var cb =1;
var aa = 0, bb =0;

while(a<bars.length/2 && b>=bars.length/2){

  if(parseInt(bars[a]) < parseInt(bars[b])){

     ca++;
     bars[b]-=bars[a];
     a++;
  }else if(parseInt(bars[a]) > parseInt(bars[b])){

     cb++;
     bars[a]-=bars[b];
     b--;
  }else{

    ca++; cb++;
    a++; b--;
  }
 //print(ca + " "+ cb);

}

if(a==b){
  if(parseInt(bars[a])<= parseInt(bars[b])) ca++;
  else cb++;
}

print(ca + " " + cb);

var n = readline().split(" ");
var bars = readline().split(" ");

var va = [];

var a = 0, b=bars.length -1;

var ca =0;
var cb =0;
var aa = 0, bb =0;

//while(a<bars.length/2 && b>=bars.length/2){
while(a<b){

  if(parseInt(bars[a]) < parseInt(bars[b])){

     ca++;
     bars[b]-=bars[a];
     a++;
  }else if(parseInt(bars[a]) > parseInt(bars[b])){

     cb++;
     bars[a]-=bars[b];
     b--;
  }else{

    ca++; cb++;
    a++; b--;
  }
 //print(ca + " "+ cb);

}

if(a==b){
  if(parseInt(bars[a])<= parseInt(bars[b])) ca++;
  else cb++;
}

print(ca + " " + cb);


There are some websites that are accessible through several different addresses. For example, for a long time Codeforces was accessible with two hostnames codeforces.com and codeforces.ru.You are given a list of page addresses being queried. For simplicity we consider all addresses to have the form http://<hostname>[/<path>], where:  <hostname> — server name (consists of words and maybe some dots separating them),  /<path> — optional part, where <path> consists of words separated by slashes. We consider two <hostname> to correspond to one website if for each query to the first <hostname> there will be exactly the same query to the second one and vice versa — for each query to the second <hostname> there will be the same query to the first one. Take a look at the samples for further clarifications.Your goal is to determine the groups of server names that correspond to one website. Ignore groups consisting of the only server name.Please note, that according to the above definition queries http://<hostname> and http://<hostname>/ are different.

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of page queries. Then follow n lines each containing exactly one address. Each address is of the form http://<hostname>[/<path>], where:   <hostname> consists of lowercase English letters and dots, there are no two consecutive dots, <hostname> doesn't start or finish with a dot. The length of <hostname> is positive and doesn't exceed 20.  <path> consists of lowercase English letters, dots and slashes. There are no two consecutive slashes, <path> doesn't start with a slash and its length doesn't exceed 20.  Addresses are not guaranteed to be distinct.

First print k — the number of groups of server names that correspond to one website. You should count only groups of size greater than one. Next k lines should contain the description of groups, one group per line. For each group print all server names separated by a single space. You are allowed to print both groups and names inside any group in arbitrary order.

10
http://abacaba.ru/test
http://abacaba.ru/
http://abacaba.com
http://abacaba.com/test
http://abacaba.de/
http://abacaba.ru/test
http://abacaba.de/test
http://abacaba.com/
http://abacaba.com/t
http://abacaba.com/test

14
http://c
http://ccc.bbbb/aba..b
http://cba.com
http://a.c/aba..b/a
http://abc/
http://a.c/
http://ccc.bbbb
http://ab.ac.bc.aa/
http://a.a.a/
http://ccc.bbbb/
http://cba.com/
http://cba.com/aba..b
http://a.a.a/aba..b/a
http://abc/aba..b/a

2
http://cba.com http://ccc.bbbb
http://a.a.a http://a.c http://abc

var l = readline();

var hosts = [];

for(var i =0; i < l; i++)
{
    var tmp = readline();
    var host = tmp.match(/(http:\/\/[^\/]+)/)[1];
    var path = tmp.match(/(http:\/\/[^\/]+)(.*)/)[2];

    if(path === '')
      path = '!!!NULL!!!';
    if(hosts[host] === void 0)
    {
      hosts[host] = [];
      hosts[host][path] = 1;
    }
    else
      hosts[host][path] += 1;
    //print(host + ' ' + path);
}

var hashes = [];

for(var i in hosts)
{
    var hash = Object.keys(hosts[i]).sort().join('-');
    if(hashes[hash] === void 0)
    {
        hashes[hash] = [];
        hashes[hash].push(i);
    }
    else
    {
        hashes[hash].push(i);
    }
}

var cnt = 0;
var output = '';
for (var i in hashes)
{
    if(hashes[i].length > 1){
         cnt++;
         output += hashes[i].join(' ') + "\n";
    }
}
print(cnt);
print(output);

var regex = /(http:\/\/[a-z\.]+)(\/?[a-z\.\/]*)/

var input = readline()

var n = Number(input)

var hosts = {}

for (var i = 0; i < n; i++) {
    input = readline()
    var parsed = regex.exec(input)
    hosts[parsed[1]] = hosts[parsed[1]] || { exists: {} }
    hosts[parsed[1]].exists[parsed[2]] = true
}

function sort (x, y) {
    return x === y
        ? 0
        : x > y
            ? 1
            : -1
}

var paths = {}

for (var name in hosts) {
    var pathsHash = Object
        .keys(hosts[name].exists)
        .sort(sort)
        .join('|')
    paths[pathsHash] = paths[pathsHash] || []
    paths[pathsHash].push(name)
}

var count = 0

var result = []

for (var hash in paths) {
    if (paths[hash].length > 1) {
        count++
        result.push(paths[hash])
    }
}

print(count)

for (var i = 0; i < count; i++) {
    print(result[i].join(' '))
}

Array.prototype.bSearchOrPush = bSearchOrPush;

function bSearchOrPush(searchElement) {
    'use strict';
    var minIndex = 0;
    var maxIndex = this.length - 1;
    var currentIndex;
    var currentElement;

    while (minIndex <= maxIndex) {
        currentIndex = (minIndex + maxIndex) / 2 | 0;
        currentElement = this[currentIndex];

        if (currentElement < searchElement) {
            minIndex = currentIndex + 1;
        }
        else if (currentElement > searchElement) {
            maxIndex = currentIndex - 1;
        }
        else {
            return false;
        }
    }

    this.splice(minIndex, 0, searchElement);
  return true;
}

var n   = +readline()
  , arr = []
  , res = []
  , gr  = 0;

for (var i = 0, query, pathIndex, host, path; i < n; i++) {
    query = readline()
    pathIndex = query.indexOf('/', 7);
    if (pathIndex > -1) {
        host = query.substring(0, pathIndex);
        path = query.substring(pathIndex);
    } else {
        host = query;
        path = '<NULL>';
    }

    if (arr[host] === undefined){
        arr[host] = [];
    }
    //bSearchOrPush(arr[host], path);
    arr[host].bSearchOrPush(path);
}

for (var h in arr){
    //print(h + ' : ' + arr[h].sort().join('-'));
    if (h != 'bSearchOrPush') {
        var pathHash = arr[h].join('-');
        //print(h + ' : ' + pathHash);
        if (res[pathHash] === undefined) {
			res[pathHash] = [];
		}
        res[pathHash].push(h);
        if (res[pathHash].length == 2) gr++;
    }
}

print(gr);
for (var r in res) {
    if (res[r].length > 1) {
        print(res[r].join(' '))
    }
}

var l = readline();

var hosts = [];

for(var i =0; i < l; i++)
{
    var tmp = readline();
    var host = tmp.match(/http:\/\/([^\/]+)/)[1];
    var path = tmp.match(/http:\/\/([^\/]+)(.*)/)[2];

    if(path === '')
      path = '!!!NULL!!!';
    if(hosts[host] === void 0)
    {
      hosts[host] = [];
      hosts[host][path] = 1;
    }
    else
      hosts[host][path] += 1;
    //print(host + ' ' + path);
}

var hashes = [];

for(var i in hosts)
{
    var hash = Object.keys(hosts[i]).sort().join('-');
    if(hashes[hash] === void 0)
    {
        hashes[hash] = [];
        hashes[hash].push(i);
    }
    else
    {
        hashes[hash].push(i);
    }
}

var cnt = 0;
var output = '';
for (var i in hashes)
{
    if(hashes[i].length > 1){
         cnt++;
         output += hashes[i].join(' ') + "\n";
    }
}
print(cnt);
print(output);