---
category_name: easy
problem_code: VK18
problem_name: 'Total Diamonds'
languages_supported:
- ADA
- ASM
- BASH
- BF
- C
- CAML
- CLOJ
- CLPS
- COB
- 'CPP 4.3.2'
- 'CPP 6.3'
- CPP14
- CS2
- D
- ERL
- FORT
- FS
- GO
- HASK
- ICK
- ICON
- JAVA
- JS
- kotlin
- 'LISP clisp'
- 'LISP sbcl'
- LUA
- NEM
- NICE
- NODEJS
- 'PAS fpc'
- 'PAS gpc'
- PERL
- PERL6
- PHP
- PIKE
- PRLG
- PYPY
- PYTH
- 'PYTH 3.5'
- RUBY
- rust
- SCALA
- 'SCM chicken'
- 'SCM guile'
- 'SCM qobi'
- ST
- swift
- TCL
- TEXT
- WSPC
max_timelimit: '1'
source_sizelimit: '50000'
problem_author: hruday968
problem_tester: null
date_added: 27-09-2017
tags:
- dec17
- hruday968
editorial_url: 'https://discuss.codechef.com/problems/VK18'
time:
view_start_date: 1512984600
submit_start_date: 1512984600
visible_start_date: 1512984600
end_date: 1735669800
current: 1514816316
layout: problem
---
All submissions for this problem are available.### Read problems statements in [Mandarin chinese](http://www.codechef.com/download/translated/DEC17/mandarin/VK18.pdf), [Russian](http://www.codechef.com/download/translated/DEC17/russian/VK18.pdf) and [Vietnamese](http://www.codechef.com/download/translated/DEC17/vietnamese/VK18.pdf) as well.
Chef is so good at programming that he won almost all competitions. With all the prizes, Chef bought a new house. The house looks like a grid of size **N** (1-indexed) which consists of **N** × **N** rooms containing diamonds. For each room, the room number is equal to the sum of the row number and the column number.
The number of diamonds present in each room is equal to the absolute difference between the sum of even digits and sum of odd digits in its room number. For example, if the room number is 3216, then the number of diamonds present in that room will be |(2+6)-(3+1)| = 4.
You are given the number **N**. You have to print the total number of diamonds present in Chef's house.
### Input
- The first line of the input contains a single integer **T** denoting the number of test cases. The description of **T** test cases follows.
- The only line of each test case contains a single integer **N**.
### Output
For each test case, print the answer on a separate line.
### Constraints
- 1 ≤ **T** ≤ 105
- 1 ≤ **N** ≤ 106
### Subtasks
**Subtask #1 (15 points):**
- 1 ≤ **T** ≤ 10
- 1 ≤ **N** ≤ 1000
**Subtask #2 (15 points):**
- 1 ≤ **T** ≤ 10
- 1 ≤ **N** ≤ 106
**Subtask #3 (70 points):** original constraints
### Example
<pre><b>Input:</b>
3
1
2
3
<b>Output:</b>
2
12
36
</pre>### Explanation
**Example case 3:** There are 9 rooms. Room (1,1) has number 2, room (1,2) has number 3, etc. For each room, the number of diamonds in it is equal to the room number, so the total number of diamonds present is (2+3+4+3+4+5+4+5+6) = 36.