New Year's Eve Party Log

No attempts yetTime limit25sMemory limit128 MB

Problem

Jarek hosted this year's New Year's Eve party. Throughout the evening he tried to keep a record of everyone entering and leaving, but he is worried that he missed a few entries and exits.

Jarek's record has N items, each in one of two forms:

  • 1 means one person entered.
  • -1 means one person left.

Given that Jarek's house was empty both before the party started and after it ended, find the minimum number of guest entries or exits that Jarek missed.

Input

The first line contains a natural number Z (1Z101 \le Z \le 10), the number of test sets. The test sets follow, one after another.

The first line of each test set contains a natural number N (1N1061 \le N \le 10^6), the number of items in Jarek's record. Each of the next N lines contains one item of the record, and each item has the form and meaning described above.

Output

For each test set, print on its own line the minimum number of items missing from Jarek's record.

Hint

  • In the first example, the only item in the record is an exit. Since the house starts empty and nobody can leave an empty house, Jarek must have missed at least one earlier event: one person entering.
  • In the second example, Jarek recorded three people entering but apparently never noticed them leaving, so at least three exits are missing.
  • In the third example, the recorded order of entries and exits is consistent on its own, so nothing is missing.