Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/Codeforces/Educational Codeforces Round 183/A. Candies for Nephews
Next
CodeforcesCodeforces
Newbie
Educational Codeforces Round 183

A. Candies for Nephews

Math
Loading...
Solve on Codeforces

Problem Statement

Official algorithmic problem description and constraints.

Open on Codeforces

Monocarp has three nephews. New Year is coming, and Monocarp has π‘›

 candies that he will gift to his nephews.

To ensure that none of the nephews feels left out, Monokarp wants to give each of the three nephews the same number of candies.

Determine the minimum number of candies that Monocarp needs to buy additionally so that he can give each of the three nephews the same number of candies. Note that all π‘›

 candies that Monocarp initially has will be given to the nephews.

Input


The first line contains an integer π‘‘

 (1≀𝑑≀100

) β€” the number of test cases.

Each test case consists of one line containing one integer π‘›

 (1≀𝑛≀100

) β€” the number of candies that Monocarp initially has.

Output


For each test case, print one integer β€” the minimum number of candies that Monokarp needs to buy additionally so that he can give each of the three nephews the same number of candies.

Example

Input

Copy

2
7
24

Output

Copy

2
0

Note


In the first example, Monocarp needs to buy 2

 candies. After that, he will have 9

 candies, and he can give each of the three nephews 3

 candies.

In the second example, Monocarp does not need to buy any candies, as he initially has 24

 candies, and he can give each of the three nephews 8

 candies.

Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Educational Codeforces Round 183
Next Problem