Another Contest 7 Problem 1 - Lonely Users

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 0.25s
Memory limit: 256M

Problem type

Ren has recently created a website, Ternary Search, which he intends on turning into the premier platform for competitive programmers to talk about anything.

In order to facilitate conversation between different users, Ren is working on a new feature called "friends". The feature will allow two distinct users to be friends. Ren is working on a prototype of this feature right now, so at present, all users are friends with Ren, and these are the only friendships present on the platform.

Including Ren, there are N users on the platform. Ren eventually wants to track a metric which he calls the "lonely user" metric, which is a count of how many users have exactly one friend. With the prototype the way it is now, how many users are lonely users?


1 \le T \le 10^4

1 \le N \le 10^9

Input Specification

The first line contains a single positive integer T, the number of test cases.

T lines follow, each line containing a single positive integer N, the number of users presently on the platform.

Output Specification

Output T lines. On the ith line, output the number of lonely users for the ith test case.

Sample Input


Sample Output



  • 0
    Viv_CCGS  commented on Oct. 27, 2021, 8:49 a.m.

    Gets every test case right except the last one :(

    • 3
      justin_g_20  commented on Oct. 28, 2021, 9:18 a.m.

      Think about how many friendships Ren will have