Vasya works as a Watchman in the gallery. Unfortunately, one of the most expensive paintings is stolen while he is on duty. He doesn ' t want to being fired, so he had to quickly restore the painting. He remembers some facts about it.
- The painting is a square 3x3 with each cell contains a single integer from 1 to n, and different cells May contain either different or equal integers.
- The sum of integers in each of four squares 2x2 are equal to the sum of integers in the top left square 2x2.
- Four elements a, b, c and D is known and is located as shown on the picture below.
Help Vasya find out the number of distinct squares the satisfy all the conditions above. Note, that this number is equal to 0, meaning Vasya remembers something wrong.
Squares is considered to being different, if there exists a cell that contains the different integers in different squar Es.
Input
The first line of the input contains five integers n, a, b, c and d (1≤ n ≤100, 1≤ a, b, c, d ≤ n)-maximum Possible value of an integer in the cell and four integers that Vasya remembers.
Output
Print one integer-the number of distinct valid squares.
Examplesinput
2 1 1) 1 2
Output
2
Input
3 3 1) 2 3
Output
6
Note
Below is all the possible paintings for the first sample.
In the second sample, only paintings displayed below satisfy all the rules.
Note The data range:
#include <iostream>using namespaceStd;typedefLong Longll;intMain () {ll n,a,b,c,d,s=0; CIN>>n>>a>>b>>c>>D; for(intI=1; i<=n;i++) {ll q1,q2,q3,q4,q5; Q1=i; Q2=q1+b-C; Q4=q1+a-D; Q5=q4+b-C; intCnt=0; if(q1>=1&&q1<=n) cnt++; if(q2>=1&&q2<=n) cnt++; if(q4>=1&&q4<=n) cnt++; if(q5>=1&&q5<=n) cnt++; if(cnt==4) s++; } cout<<s*N;}
Codeforces Round #353 (Div. 2) Restoring Painting