When's the nearest special common year? A common year is a year that is not a leap year and where the first and last day of the year are on the same day. A special common year is one that starts on a Monday and so ends on a Monday as well. 

Your challenge is to create a program/function that when given a year as input finds the nearest special common year, outputting itself if it is a common year. If the year is as close to the one before it as the one next to it output the larger one.

Input

An integer representing the year to test against in the range 1600 &lt;= x &lt;= 2100.

Output

An integer representing the nearest special common year.

Test cases

2017 -&gt; 2018
2018 -&gt; 2018
1992 -&gt; 1990
1600 -&gt; 1601
2100 -&gt; 2103
1728 -&gt; 1731 (lies between 1725 and 1731)


Notes

All 54 years in the given range are already shown in the linked Wikipedia article. I will also provide them here for reference:

1601, 1607, 1618, 1629, 1635, 1646, 1657, 1663, 1674, 1685, 1691
1703, 1714, 1725, 1731, 1742, 1753, 1759, 1770, 1781, 1787, 1798
1810, 1821, 1827, 1838, 1849, 1855, 1866, 1877, 1883, 1894, 1900
1906, 1917, 1923, 1934, 1945, 1951, 1962, 1973, 1979, 1990
2001, 2007, 2018, 2029, 2035, 2046, 2057, 2063, 2074, 2085, 2091
2103 (Needed for 2097 to 2100)
PHP, 67 Bytes

for(;date(LN,mktime(0,0,0,1,1,$y=$argn+$i))&gt;1;)$i=($i&lt;1)-$i;echo$y;


Try it online!

or


for(;date(LN,strtotime("1/1/".$y=$argn+$i))&gt;1;)$i=($i&lt;1)-$i;echo$y;


Try it online!

Expanded

for(;
date(LN,mktime(0,0,0,1,1,$y=$argn+$i)) # N is 1 for Monday and L is 0 for Non leap year
&gt;1;) # loop so long as expression is not 1
  $i=($i&lt;1)-$i; # set $i 0,1,-1,2,-2 ...
echo$y; # Output Year


date