#!/usr/local/bin/perl
use warnings;
use strict;
#use explicit;

#----PARAMETERS:

# histogram 
#
my @unsortedRepIons = (500.3,501.3,502.3,503.3,504.3,505.3,506.3,507.3,508.3,509.3,510.3,511.3,512.3,513.3,514.3,515.3,516.3,517.3,518.3,519.3,520.3,521.3,522.3,523.3,524.3,525.3,526.3,527.3,528.3,529.3,530.3,531.3,532.3,533.3,534.3,535.3,536.3,537.3,538.3,539.3,540.3,541.3,542.3,543.3,544.3,545.3,546.3,547.3,548.3,549.3,550.3,551.3,552.3,553.3,554.3,555.3,556.3,557.3,558.3,559.3,560.3,561.3,562.3,563.3,564.3,565.3,566.3,567.3,568.3,569.3,570.3,571.3,572.3,573.3,574.3,575.3,576.3,577.3,578.3,579.3,580.3,581.3,582.3,583.3,584.3,585.3,586.3,587.3,588.3,589.3,590.3,591.3,592.3,593.3,594.3,595.3,596.3,597.3,598.3,599.3,600.3,601.3,602.3,603.3,604.3,605.3,606.3,607.3,608.3,609.3,610.3,611.3,612.3,613.3,614.3,615.3,616.3,617.3,618.3,619.3,620.3,621.3,622.3,623.3,624.3,625.3,626.3,627.3,628.3,629.3,630.3,631.3,632.3,633.3,634.3,635.3,636.3,637.3,638.3,639.3,640.3,641.3,642.3,643.3,644.3,645.3,646.3,647.3,648.3,649.3,650.3,651.3,652.3,653.3,654.3,655.3,656.3,657.3,658.3,659.3,660.3,661.3,662.3,663.3,664.3,665.3,666.3,667.3,668.3,669.3,670.3,671.3,672.3,673.3,674.3,675.3,676.3,677.3,678.3,679.3,680.3,681.3,682.3,683.3,684.3,685.3,686.3,687.3,688.3,689.3,690.3,691.3,692.3,693.3,694.3,695.3,696.3,697.3,698.3,699.3,700.3,701.3,702.3,703.3,704.3,705.3,706.3,707.3,708.3,709.3,710.3,711.3,712.3,713.3,714.3,715.3,716.3,717.3,718.3,719.3,720.3,721.3,722.3,723.3,724.3,725.3,726.3,727.3,728.3,729.3,730.3,731.3,732.3,733.3,734.3,735.3,736.3,737.3,738.3,739.3,740.3,741.3,742.3,743.3,744.3,745.3,746.3,747.3,748.3,749.3,750.3,751.3,752.3,753.3,754.3,755.3,756.3,757.3,758.3,759.3,760.3,761.3,762.3,763.3,764.3,765.3,766.3,767.3,768.3,769.3,770.3,771.3,772.3,773.3,774.3,775.3,776.3,777.3,778.3,779.3,780.3,781.3,782.3,783.3,784.3,785.3,786.3,787.3,788.3,789.3,790.3,791.3,792.3,793.3,794.3,795.3,796.3,797.3,798.3,799.3,800.3,801.3,802.3,803.3,804.3,805.3,806.3,807.3,808.3,809.3,810.3,811.3,812.3,813.3,814.3,815.3,816.3,817.3,818.3,819.3,820.3,821.3,822.3,823.3,824.3,825.3,826.3,827.3,828.3,829.3,830.3,831.3,832.3,833.3,834.3,835.3,836.3,837.3,838.3,839.3,840.3,841.3,842.3,843.3,844.3,845.3,846.3,847.3,848.3,849.3,850.3,851.3,852.3,853.3,854.3,855.3,856.3,857.3,858.3,859.3,860.3,861.3,862.3,863.3,864.3,865.3,866.3,867.3,868.3,869.3,870.3,871.3,872.3,873.3,874.3,875.3,876.3,877.3,878.3,879.3,880.3,881.3,882.3,883.3,884.3,885.3,886.3,887.3,888.3,889.3,890.3,891.3,892.3,893.3,894.3,895.3,896.3,897.3,898.3,899.3,900.3,901.3,902.3,903.3,904.3,905.3,906.3,907.3,908.3,909.3,910.3,911.3,912.3,913.3,914.3,915.3,916.3,917.3,918.3,919.3,920.3,921.3,922.3,923.3,924.3,925.3,926.3,927.3,928.3,929.3,930.3,931.3,932.3,933.3,934.3,935.3,936.3,937.3,938.3,939.3,940.3,941.3,942.3,943.3,944.3,945.3,946.3,947.3,948.3,949.3,950.3,951.3,952.3,953.3,954.3,955.3,956.3,957.3,958.3,959.3,960.3,961.3,962.3,963.3,964.3,965.3,966.3,967.3,968.3,969.3,970.3,971.3,972.3,973.3,974.3,975.3,976.3,977.3,978.3,979.3,980.3,981.3,982.3,983.3,984.3,985.3,986.3,987.3,988.3,989.3,990.3,991.3,992.3,993.3,994.3,995.3,996.3,997.3,998.3,999.3,1000.3,1001.3,1002.3,1003.3,1004.3,1005.3,1006.3,1007.3,1008.3,1009.3,1010.3,1011.3,1012.3,1013.3,1014.3,1015.3,1016.3,1017.3,1018.3,1019.3,1020.3,1021.3,1022.3,1023.3,1024.3,1025.3,1026.3,1027.3,1028.3,1029.3,1030.3,1031.3,1032.3,1033.3,1034.3,1035.3,1036.3,1037.3,1038.3,1039.3,1040.3,1041.3,1042.3,1043.3,1044.3,1045.3,1046.3,1047.3,1048.3,1049.3,1050.3,1051.3,1052.3,1053.3,1054.3,1055.3,1056.3,1057.3,1058.3,1059.3,1060.3,1061.3,1062.3,1063.3,1064.3,1065.3,1066.3,1067.3,1068.3,1069.3,1070.3,1071.3,1072.3,1073.3,1074.3,1075.3,1076.3,1077.3,1078.3,1079.3,1080.3,1081.3,1082.3,1083.3,1084.3,1085.3,1086.3,1087.3,1088.3,1089.3,1090.3,1091.3,1092.3,1093.3,1094.3,1095.3,1096.3,1097.3,1098.3,1099.3,1100.3,1101.3,1102.3,1103.3,1104.3,1105.3,1106.3,1107.3,1108.3,1109.3,1110.3,1111.3,1112.3,1113.3,1114.3,1115.3,1116.3,1117.3,1118.3,1119.3,1120.3,1121.3,1122.3,1123.3,1124.3,1125.3,1126.3,1127.3,1128.3,1129.3,1130.3,1131.3,1132.3,1133.3,1134.3,1135.3,1136.3,1137.3,1138.3,1139.3,1140.3,1141.3,1142.3,1143.3,1144.3,1145.3,1146.3,1147.3,1148.3,1149.3,1150.3,1151.3,1152.3,1153.3,1154.3,1155.3,1156.3,1157.3,1158.3,1159.3,1160.3,1161.3,1162.3,1163.3,1164.3,1165.3,1166.3,1167.3,1168.3,1169.3,1170.3,1171.3,1172.3,1173.3,1174.3,1175.3,1176.3,1177.3,1178.3,1179.3,1180.3,1181.3,1182.3,1183.3,1184.3,1185.3,1186.3,1187.3,1188.3,1189.3,1190.3,1191.3,1192.3,1193.3,1194.3,1195.3,1196.3,1197.3,1198.3,1199.3,1200.3,1201.3,1202.3,1203.3,1204.3,1205.3,1206.3,1207.3,1208.3,1209.3,1210.3,1211.3,1212.3,1213.3,1214.3,1215.3,1216.3,1217.3,1218.3,1219.3,1220.3,1221.3,1222.3,1223.3,1224.3,1225.3,1226.3,1227.3,1228.3,1229.3,1230.3,1231.3,1232.3,1233.3,1234.3,1235.3,1236.3,1237.3,1238.3,1239.3,1240.3,1241.3,1242.3,1243.3,1244.3,1245.3,1246.3,1247.3,1248.3,1249.3,1250.3,1251.3,1252.3,1253.3,1254.3,1255.3,1256.3,1257.3,1258.3,1259.3,1260.3,1261.3,1262.3,1263.3,1264.3,1265.3,1266.3,1267.3,1268.3,1269.3,1270.3,1271.3,1272.3,1273.3,1274.3,1275.3,1276.3,1277.3,1278.3,1279.3,1280.3,1281.3,1282.3,1283.3,1284.3,1285.3,1286.3,1287.3,1288.3,1289.3,1290.3,1291.3,1292.3,1293.3,1294.3,1295.3,1296.3,1297.3,1298.3,1299.3,1300.3,1301.3,1302.3,1303.3,1304.3,1305.3,1306.3,1307.3,1308.3,1309.3,1310.3,1311.3,1312.3,1313.3,1314.3,1315.3,1316.3,1317.3,1318.3,1319.3,1320.3,1321.3,1322.3,1323.3,1324.3,1325.3,1326.3,1327.3,1328.3,1329.3,1330.3,1331.3,1332.3,1333.3,1334.3,1335.3,1336.3,1337.3,1338.3,1339.3,1340.3,1341.3,1342.3,1343.3,1344.3,1345.3,1346.3,1347.3,1348.3,1349.3,1350.3,1351.3,1352.3,1353.3,1354.3,1355.3,1356.3,1357.3,1358.3,1359.3,1360.3,1361.3,1362.3,1363.3,1364.3,1365.3,1366.3,1367.3,1368.3,1369.3,1370.3,1371.3,1372.3,1373.3,1374.3,1375.3,1376.3,1377.3,1378.3,1379.3,1380.3,1381.3,1382.3,1383.3,1384.3,1385.3,1386.3,1387.3,1388.3,1389.3,1390.3,1391.3,1392.3,1393.3,1394.3,1395.3,1396.3,1397.3,1398.3,1399.3,1400.3,1401.3,1402.3,1403.3,1404.3,1405.3,1406.3,1407.3,1408.3,1409.3,1410.3,1411.3,1412.3,1413.3,1414.3,1415.3,1416.3,1417.3,1418.3,1419.3,1420.3,1421.3,1422.3,1423.3,1424.3,1425.3,1426.3,1427.3,1428.3,1429.3,1430.3,1431.3,1432.3,1433.3,1434.3,1435.3,1436.3,1437.3,1438.3,1439.3,1440.3,1441.3,1442.3,1443.3,1444.3,1445.3,1446.3,1447.3,1448.3,1449.3,1450.3,1451.3,1452.3,1453.3,1454.3,1455.3,1456.3,1457.3,1458.3,1459.3,1460.3,1461.3,1462.3,1463.3,1464.3,1465.3,1466.3,1467.3,1468.3,1469.3,1470.3,1471.3,1472.3,1473.3,1474.3,1475.3,1476.3,1477.3,1478.3,1479.3,1480.3,1481.3,1482.3,1483.3,1484.3,1485.3,1486.3,1487.3,1488.3,1489.3,1490.3,1491.3,1492.3,1493.3,1494.3,1495.3,1496.3,1497.3,1498.3,1499.3,1500.3,1501.3,1502.3,1503.3,1504.3,1505.3,1506.3,1507.3,1508.3,1509.3,1510.3,1511.3,1512.3,1513.3,1514.3,1515.3,1516.3,1517.3,1518.3,1519.3,1520.3,1521.3,1522.3,1523.3,1524.3,1525.3,1526.3,1527.3,1528.3,1529.3,1530.3,1531.3,1532.3,1533.3,1534.3,1535.3,1536.3,1537.3,1538.3,1539.3,1540.3,1541.3,1542.3,1543.3,1544.3,1545.3,1546.3,1547.3,1548.3,1549.3,1550.3,1551.3,1552.3,1553.3,1554.3,1555.3,1556.3,1557.3,1558.3,1559.3,1560.3,1561.3,1562.3,1563.3,1564.3,1565.3,1566.3,1567.3,1568.3,1569.3,1570.3,1571.3,1572.3,1573.3,1574.3,1575.3,1576.3,1577.3,1578.3,1579.3,1580.3,1581.3,1582.3,1583.3,1584.3,1585.3,1586.3,1587.3,1588.3,1589.3,1590.3,1591.3,1592.3,1593.3,1594.3,1595.3,1596.3,1597.3,1598.3,1599.3,1600.3,1601.3,1602.3,1603.3,1604.3,1605.3,1606.3,1607.3,1608.3,1609.3,1610.3,1611.3,1612.3,1613.3,1614.3,1615.3,1616.3,1617.3,1618.3,1619.3,1620.3,1621.3,1622.3,1623.3,1624.3,1625.3,1626.3,1627.3,1628.3,1629.3,1630.3,1631.3,1632.3,1633.3,1634.3,1635.3,1636.3,1637.3,1638.3,1639.3,1640.3,1641.3,1642.3,1643.3,1644.3,1645.3,1646.3,1647.3,1648.3,1649.3,1650.3,1651.3,1652.3,1653.3,1654.3,1655.3,1656.3,1657.3,1658.3,1659.3,1660.3,1661.3,1662.3,1663.3,1664.3,1665.3,1666.3,1667.3,1668.3,1669.3,1670.3,1671.3,1672.3,1673.3,1674.3,1675.3,1676.3,1677.3,1678.3,1679.3,1680.3,1681.3,1682.3,1683.3,1684.3,1685.3,1686.3,1687.3,1688.3,1689.3,1690.3,1691.3,1692.3,1693.3,1694.3,1695.3,1696.3,1697.3,1698.3,1699.3,1700.3,1701.3,1702.3,1703.3,1704.3,1705.3,1706.3,1707.3,1708.3,1709.3,1710.3,1711.3,1712.3,1713.3,1714.3,1715.3,1716.3,1717.3,1718.3,1719.3,1720.3,1721.3,1722.3,1723.3,1724.3,1725.3,1726.3,1727.3,1728.3,1729.3,1730.3,1731.3,1732.3,1733.3,1734.3,1735.3,1736.3,1737.3,1738.3,1739.3,1740.3,1741.3,1742.3,1743.3,1744.3,1745.3,1746.3,1747.3,1748.3,1749.3,1750.3,1751.3,1752.3,1753.3,1754.3,1755.3,1756.3,1757.3,1758.3,1759.3,1760.3,1761.3,1762.3,1763.3,1764.3,1765.3,1766.3,1767.3,1768.3,1769.3,1770.3,1771.3,1772.3,1773.3,1774.3,1775.3,1776.3,1777.3,1778.3,1779.3,1780.3,1781.3,1782.3,1783.3,1784.3,1785.3,1786.3,1787.3,1788.3,1789.3,1790.3,1791.3,1792.3,1793.3,1794.3,1795.3,1796.3,1797.3,1798.3,1799.3,1800.3,1801.3,1802.3,1803.3,1804.3,1805.3,1806.3,1807.3,1808.3,1809.3,1810.3,1811.3,1812.3,1813.3,1814.3,1815.3,1816.3,1817.3,1818.3,1819.3,1820.3,1821.3,1822.3,1823.3,1824.3,1825.3,1826.3,1827.3,1828.3,1829.3,1830.3,1831.3,1832.3,1833.3,1834.3,1835.3,1836.3,1837.3,1838.3,1839.3,1840.3,1841.3,1842.3,1843.3,1844.3,1845.3,1846.3,1847.3,1848.3,1849.3,1850.3,1851.3,1852.3,1853.3,1854.3,1855.3,1856.3,1857.3,1858.3,1859.3,1860.3,1861.3,1862.3,1863.3,1864.3,1865.3,1866.3,1867.3,1868.3,1869.3,1870.3,1871.3,1872.3,1873.3,1874.3,1875.3,1876.3,1877.3,1878.3,1879.3,1880.3,1881.3,1882.3,1883.3,1884.3,1885.3,1886.3,1887.3,1888.3,1889.3,1890.3,1891.3,1892.3,1893.3,1894.3,1895.3,1896.3,1897.3,1898.3,1899.3,1900.3,1901.3,1902.3,1903.3,1904.3,1905.3,1906.3,1907.3,1908.3,1909.3,1910.3,1911.3,1912.3,1913.3,1914.3,1915.3,1916.3,1917.3,1918.3,1919.3,1920.3,1921.3,1922.3,1923.3,1924.3,1925.3,1926.3,1927.3,1928.3,1929.3,1930.3,1931.3,1932.3,1933.3,1934.3,1935.3,1936.3,1937.3,1938.3,1939.3,1940.3,1941.3,1942.3,1943.3,1944.3,1945.3,1946.3,1947.3,1948.3,1949.3,1950.3,1951.3,1952.3,1953.3,1954.3,1955.3,1956.3,1957.3,1958.3,1959.3,1960.3,1961.3,1962.3,1963.3,1964.3,1965.3,1966.3,1967.3,1968.3,1969.3,1970.3,1971.3,1972.3,1973.3,1974.3,1975.3,1976.3,1977.3,1978.3,1979.3,1980.3,1981.3,1982.3,1983.3,1984.3,1985.3,1986.3,1987.3,1988.3,1989.3,1990.3,1991.3,1992.3,1993.3,1994.3,1995.3,1996.3,1997.3,1998.3,1999.3,2000.3,2001.3,2002.3,2003.3,2004.3,2005.3,2006.3,2007.3,2008.3,2009.3,2010.3,2011.3,2012.3,2013.3,2014.3,2015.3,2016.3,2017.3,2018.3,2019.3,2020.3,2021.3,2022.3,2023.3,2024.3,2025.3,2026.3,2027.3,2028.3,2029.3,2030.3,2031.3,2032.3,2033.3,2034.3,2035.3,2036.3,2037.3,2038.3,2039.3,2040.3,2041.3,2042.3,2043.3,2044.3,2045.3,2046.3,2047.3,2048.3,2049.3,2050.3,2051.3,2052.3,2053.3,2054.3,2055.3,2056.3,2057.3,2058.3,2059.3,2060.3,2061.3,2062.3,2063.3,2064.3,2065.3,2066.3,2067.3,2068.3,2069.3,2070.3,2071.3,2072.3,2073.3,2074.3,2075.3,2076.3,2077.3,2078.3,2079.3,2080.3,2081.3,2082.3,2083.3,2084.3,2085.3,2086.3,2087.3,2088.3,2089.3,2090.3,2091.3,2092.3,2093.3,2094.3,2095.3,2096.3,2097.3,2098.3,2099.3,2100.3,2101.3,2102.3,2103.3,2104.3,2105.3,2106.3,2107.3,2108.3,2109.3,2110.3,2111.3,2112.3,2113.3,2114.3,2115.3,2116.3,2117.3,2118.3,2119.3,2120.3,2121.3,2122.3,2123.3,2124.3,2125.3,2126.3,2127.3,2128.3,2129.3,2130.3,2131.3,2132.3,2133.3,2134.3,2135.3,2136.3,2137.3,2138.3,2139.3,2140.3,2141.3,2142.3,2143.3,2144.3,2145.3,2146.3,2147.3,2148.3,2149.3,2150.3,2151.3,2152.3,2153.3,2154.3,2155.3,2156.3,2157.3,2158.3,2159.3,2160.3,2161.3,2162.3,2163.3,2164.3,2165.3,2166.3,2167.3,2168.3,2169.3,2170.3,2171.3,2172.3,2173.3,2174.3,2175.3,2176.3,2177.3,2178.3,2179.3,2180.3,2181.3,2182.3,2183.3,2184.3,2185.3,2186.3,2187.3,2188.3,2189.3,2190.3,2191.3,2192.3,2193.3,2194.3,2195.3,2196.3,2197.3,2198.3,2199.3,2200.3,2201.3,2202.3,2203.3,2204.3,2205.3,2206.3,2207.3,2208.3,2209.3,2210.3,2211.3,2212.3,2213.3,2214.3,2215.3,2216.3,2217.3,2218.3,2219.3,2220.3,2221.3,2222.3,2223.3,2224.3,2225.3,2226.3,2227.3,2228.3,2229.3,2230.3,2231.3,2232.3,2233.3,2234.3,2235.3,2236.3,2237.3,2238.3,2239.3,2240.3,2241.3,2242.3,2243.3,2244.3,2245.3,2246.3,2247.3,2248.3,2249.3,2250.3,2251.3,2252.3,2253.3,2254.3,2255.3,2256.3,2257.3,2258.3,2259.3,2260.3,2261.3,2262.3,2263.3,2264.3,2265.3,2266.3,2267.3,2268.3,2269.3,2270.3,2271.3,2272.3,2273.3,2274.3,2275.3,2276.3,2277.3,2278.3,2279.3,2280.3,2281.3,2282.3,2283.3,2284.3,2285.3,2286.3,2287.3,2288.3,2289.3,2290.3,2291.3,2292.3,2293.3,2294.3,2295.3,2296.3,2297.3,2298.3,2299.3,2300.3,2301.3,2302.3,2303.3,2304.3,2305.3,2306.3,2307.3,2308.3,2309.3,2310.3,2311.3,2312.3,2313.3,2314.3,2315.3,2316.3,2317.3,2318.3,2319.3,2320.3,2321.3,2322.3,2323.3,2324.3,2325.3,2326.3,2327.3,2328.3,2329.3,2330.3,2331.3,2332.3,2333.3,2334.3,2335.3,2336.3,2337.3,2338.3,2339.3,2340.3,2341.3,2342.3,2343.3,2344.3,2345.3,2346.3,2347.3,2348.3,2349.3,2350.3,2351.3,2352.3,2353.3,2354.3,2355.3,2356.3,2357.3,2358.3,2359.3,2360.3,2361.3,2362.3,2363.3,2364.3,2365.3,2366.3,2367.3,2368.3,2369.3,2370.3,2371.3,2372.3,2373.3,2374.3,2375.3,2376.3,2377.3,2378.3,2379.3,2380.3,2381.3,2382.3,2383.3,2384.3,2385.3,2386.3,2387.3,2388.3,2389.3,2390.3,2391.3,2392.3,2393.3,2394.3,2395.3,2396.3,2397.3,2398.3,2399.3,2400.3,2401.3,2402.3,2403.3,2404.3,2405.3,2406.3,2407.3,2408.3,2409.3,2410.3,2411.3,2412.3,2413.3,2414.3,2415.3,2416.3,2417.3,2418.3,2419.3,2420.3,2421.3,2422.3,2423.3,2424.3,2425.3,2426.3,2427.3,2428.3,2429.3,2430.3,2431.3,2432.3,2433.3,2434.3,2435.3,2436.3,2437.3,2438.3,2439.3,2440.3,2441.3,2442.3,2443.3,2444.3,2445.3,2446.3,2447.3,2448.3,2449.3,2450.3,2451.3,2452.3,2453.3,2454.3,2455.3,2456.3,2457.3,2458.3,2459.3,2460.3,2461.3,2462.3,2463.3,2464.3,2465.3,2466.3,2467.3,2468.3,2469.3,2470.3,2471.3,2472.3,2473.3,2474.3,2475.3,2476.3,2477.3,2478.3,2479.3,2480.3,2481.3,2482.3,2483.3,2484.3,2485.3,2486.3,2487.3,2488.3,2489.3,2490.3,2491.3,2492.3,2493.3,2494.3,2495.3,2496.3,2497.3,2498.3,2499.3,2500.3,2501.3,2502.3,2503.3,2504.3,2505.3,2506.3,2507.3,2508.3,2509.3,2510.3,2511.3,2512.3,2513.3,2514.3,2515.3,2516.3,2517.3,2518.3,2519.3,2520.3,2521.3,2522.3,2523.3,2524.3,2525.3,2526.3,2527.3,2528.3,2529.3,2530.3,2531.3,2532.3,2533.3,2534.3,2535.3,2536.3,2537.3,2538.3,2539.3,2540.3,2541.3,2542.3,2543.3,2544.3,2545.3,2546.3,2547.3,2548.3,2549.3,2550.3,2551.3,2552.3,2553.3,2554.3,2555.3,2556.3,2557.3,2558.3,2559.3,2560.3,2561.3,2562.3,2563.3,2564.3,2565.3,2566.3,2567.3,2568.3,2569.3,2570.3,2571.3,2572.3,2573.3,2574.3,2575.3,2576.3,2577.3,2578.3,2579.3,2580.3,2581.3,2582.3,2583.3,2584.3,2585.3,2586.3,2587.3,2588.3,2589.3,2590.3,2591.3,2592.3,2593.3,2594.3,2595.3,2596.3,2597.3,2598.3,2599.3,2600.3,2601.3,2602.3,2603.3,2604.3,2605.3,2606.3,2607.3,2608.3,2609.3,2610.3,2611.3,2612.3,2613.3,2614.3,2615.3,2616.3,2617.3,2618.3,2619.3,2620.3,2621.3,2622.3,2623.3,2624.3,2625.3,2626.3,2627.3,2628.3,2629.3,2630.3,2631.3,2632.3,2633.3,2634.3,2635.3,2636.3,2637.3,2638.3,2639.3,2640.3,2641.3,2642.3,2643.3,2644.3,2645.3,2646.3,2647.3,2648.3,2649.3,2650.3,2651.3,2652.3,2653.3,2654.3,2655.3,2656.3,2657.3,2658.3,2659.3,2660.3,2661.3,2662.3,2663.3,2664.3,2665.3,2666.3,2667.3,2668.3,2669.3,2670.3,2671.3,2672.3,2673.3,2674.3,2675.3,2676.3,2677.3,2678.3,2679.3,2680.3,2681.3,2682.3,2683.3,2684.3,2685.3,2686.3,2687.3,2688.3,2689.3,2690.3,2691.3,2692.3,2693.3,2694.3,2695.3,2696.3,2697.3,2698.3,2699.3,2700.3,2701.3,2702.3,2703.3,2704.3,2705.3,2706.3,2707.3,2708.3,2709.3,2710.3,2711.3,2712.3,2713.3,2714.3,2715.3,2716.3,2717.3,2718.3,2719.3,2720.3,2721.3,2722.3,2723.3,2724.3,2725.3,2726.3,2727.3,2728.3,2729.3,2730.3,2731.3,2732.3,2733.3,2734.3,2735.3,2736.3,2737.3,2738.3,2739.3,2740.3,2741.3,2742.3,2743.3,2744.3,2745.3,2746.3,2747.3,2748.3,2749.3,2750.3,2751.3,2752.3,2753.3,2754.3,2755.3,2756.3,2757.3,2758.3,2759.3,2760.3,2761.3,2762.3,2763.3,2764.3,2765.3,2766.3,2767.3,2768.3,2769.3,2770.3,2771.3,2772.3,2773.3,2774.3,2775.3,2776.3,2777.3,2778.3,2779.3,2780.3,2781.3,2782.3,2783.3,2784.3,2785.3,2786.3,2787.3,2788.3,2789.3,2790.3,2791.3,2792.3,2793.3,2794.3,2795.3,2796.3,2797.3,2798.3,2799.3,2800.3,2801.3,2802.3,2803.3,2804.3,2805.3,2806.3,2807.3,2808.3,2809.3,2810.3,2811.3,2812.3,2813.3,2814.3,2815.3,2816.3,2817.3,2818.3,2819.3,2820.3,2821.3,2822.3,2823.3,2824.3,2825.3,2826.3,2827.3,2828.3,2829.3,2830.3,2831.3,2832.3,2833.3,2834.3,2835.3,2836.3,2837.3,2838.3,2839.3,2840.3,2841.3,2842.3,2843.3,2844.3,2845.3,2846.3,2847.3,2848.3,2849.3,2850.3,2851.3,2852.3,2853.3,2854.3,2855.3,2856.3,2857.3,2858.3,2859.3,2860.3,2861.3,2862.3,2863.3,2864.3,2865.3,2866.3,2867.3,2868.3,2869.3,2870.3,2871.3,2872.3,2873.3,2874.3,2875.3,2876.3,2877.3,2878.3,2879.3,2880.3,2881.3,2882.3,2883.3,2884.3,2885.3,2886.3,2887.3,2888.3,2889.3,2890.3,2891.3,2892.3,2893.3,2894.3,2895.3,2896.3,2897.3,2898.3,2899.3,2900.3,2901.3,2902.3,2903.3,2904.3,2905.3,2906.3,2907.3,2908.3,2909.3,2910.3,2911.3,2912.3,2913.3,2914.3,2915.3,2916.3,2917.3,2918.3,2919.3,2920.3,2921.3,2922.3,2923.3,2924.3,2925.3,2926.3,2927.3,2928.3,2929.3,2930.3,2931.3,2932.3,2933.3,2934.3,2935.3,2936.3,2937.3,2938.3,2939.3,2940.3,2941.3,2942.3,2943.3,2944.3,2945.3,2946.3,2947.3,2948.3,2949.3,2950.3,2951.3,2952.3,2953.3,2954.3,2955.3,2956.3,2957.3,2958.3,2959.3,2960.3,2961.3,2962.3,2963.3,2964.3,2965.3,2966.3,2967.3,2968.3,2969.3,2970.3,2971.3,2972.3,2973.3,2974.3,2975.3,2976.3,2977.3,2978.3,2979.3,2980.3,2981.3,2982.3,2983.3,2984.3,2985.3,2986.3,2987.3,2988.3,2989.3,2990.3,2991.3,2992.3,2993.3,2994.3,2995.3,2996.3,2997.3,2998.3,2999.3,3000.3,3001.3,3002.3,3003.3,3004.3,3005.3,3006.3,3007.3,3008.3,3009.3,3010.3,3011.3,3012.3,3013.3,3014.3,3015.3,3016.3,3017.3,3018.3,3019.3,3020.3,3021.3,3022.3,3023.3,3024.3,3025.3,3026.3,3027.3,3028.3,3029.3,3030.3,3031.3,3032.3,3033.3,3034.3,3035.3,3036.3,3037.3,3038.3,3039.3,3040.3,3041.3,3042.3,3043.3,3044.3,3045.3,3046.3,3047.3,3048.3,3049.3,3050.3,3051.3,3052.3,3053.3,3054.3,3055.3,3056.3,3057.3,3058.3,3059.3,3060.3,3061.3,3062.3,3063.3,3064.3,3065.3,3066.3,3067.3,3068.3,3069.3,3070.3,3071.3,3072.3,3073.3,3074.3,3075.3,3076.3,3077.3,3078.3,3079.3,3080.3,3081.3,3082.3,3083.3,3084.3,3085.3,3086.3,3087.3,3088.3,3089.3,3090.3,3091.3,3092.3,3093.3,3094.3,3095.3,3096.3,3097.3,3098.3,3099.3,3100.3,3101.3,3102.3,3103.3,3104.3,3105.3,3106.3,3107.3,3108.3,3109.3,3110.3,3111.3,3112.3,3113.3,3114.3,3115.3,3116.3,3117.3,3118.3,3119.3,3120.3,3121.3,3122.3,3123.3,3124.3,3125.3,3126.3,3127.3,3128.3,3129.3,3130.3,3131.3,3132.3,3133.3,3134.3,3135.3,3136.3,3137.3,3138.3,3139.3,3140.3,3141.3,3142.3,3143.3,3144.3,3145.3,3146.3,3147.3,3148.3,3149.3,3150.3,3151.3,3152.3,3153.3,3154.3,3155.3,3156.3,3157.3,3158.3,3159.3,3160.3,3161.3,3162.3,3163.3,3164.3,3165.3,3166.3,3167.3,3168.3,3169.3,3170.3,3171.3,3172.3,3173.3,3174.3,3175.3,3176.3,3177.3,3178.3,3179.3,3180.3,3181.3,3182.3,3183.3,3184.3,3185.3,3186.3,3187.3,3188.3,3189.3,3190.3,3191.3,3192.3,3193.3,3194.3,3195.3,3196.3,3197.3,3198.3,3199.3,3200.3,3201.3,3202.3,3203.3,3204.3,3205.3,3206.3,3207.3,3208.3,3209.3,3210.3,3211.3,3212.3,3213.3,3214.3,3215.3,3216.3,3217.3,3218.3,3219.3,3220.3,3221.3,3222.3,3223.3,3224.3,3225.3,3226.3,3227.3,3228.3,3229.3,3230.3,3231.3,3232.3,3233.3,3234.3,3235.3,3236.3,3237.3,3238.3,3239.3,3240.3,3241.3,3242.3,3243.3,3244.3,3245.3,3246.3,3247.3,3248.3,3249.3,3250.3,3251.3,3252.3,3253.3,3254.3,3255.3,3256.3,3257.3,3258.3,3259.3,3260.3,3261.3,3262.3,3263.3,3264.3,3265.3,3266.3,3267.3,3268.3,3269.3,3270.3,3271.3,3272.3,3273.3,3274.3,3275.3,3276.3,3277.3,3278.3,3279.3,3280.3,3281.3,3282.3,3283.3,3284.3,3285.3,3286.3,3287.3,3288.3,3289.3,3290.3,3291.3,3292.3,3293.3,3294.3,3295.3,3296.3,3297.3,3298.3,3299.3,3300.3,3301.3,3302.3,3303.3,3304.3,3305.3,3306.3,3307.3,3308.3,3309.3,3310.3,3311.3,3312.3,3313.3,3314.3,3315.3,3316.3,3317.3,3318.3,3319.3,3320.3,3321.3,3322.3,3323.3,3324.3,3325.3,3326.3,3327.3,3328.3,3329.3,3330.3,3331.3,3332.3,3333.3,3334.3,3335.3,3336.3,3337.3,3338.3,3339.3,3340.3,3341.3,3342.3,3343.3,3344.3,3345.3,3346.3,3347.3,3348.3,3349.3,3350.3,3351.3,3352.3,3353.3,3354.3,3355.3,3356.3,3357.3,3358.3,3359.3,3360.3,3361.3,3362.3,3363.3,3364.3,3365.3,3366.3,3367.3,3368.3,3369.3,3370.3,3371.3,3372.3,3373.3,3374.3,3375.3,3376.3,3377.3,3378.3,3379.3,3380.3,3381.3,3382.3,3383.3,3384.3,3385.3,3386.3,3387.3,3388.3,3389.3,3390.3,3391.3,3392.3,3393.3,3394.3,3395.3,3396.3,3397.3,3398.3,3399.3,3400.3,3401.3,3402.3,3403.3,3404.3,3405.3,3406.3,3407.3,3408.3,3409.3,3410.3,3411.3,3412.3,3413.3,3414.3,3415.3,3416.3,3417.3,3418.3,3419.3,3420.3,3421.3,3422.3,3423.3,3424.3,3425.3,3426.3,3427.3,3428.3,3429.3,3430.3,3431.3,3432.3,3433.3,3434.3,3435.3,3436.3,3437.3,3438.3,3439.3,3440.3,3441.3,3442.3,3443.3,3444.3,3445.3,3446.3,3447.3,3448.3,3449.3,3450.3,3451.3,3452.3,3453.3,3454.3,3455.3,3456.3,3457.3,3458.3,3459.3,3460.3,3461.3,3462.3,3463.3,3464.3,3465.3,3466.3,3467.3,3468.3,3469.3,3470.3,3471.3,3472.3,3473.3,3474.3,3475.3,3476.3,3477.3,3478.3,3479.3,3480.3,3481.3,3482.3,3483.3,3484.3,3485.3,3486.3,3487.3,3488.3,3489.3,3490.3,3491.3,3492.3,3493.3,3494.3,3495.3,3496.3,3497.3,3498.3,3499.3,3500.3,3501.3,3502.3,3503.3,3504.3,3505.3,3506.3,3507.3,3508.3,3509.3,3510.3,3511.3,3512.3,3513.3,3514.3,3515.3,3516.3,3517.3,3518.3,3519.3,3520.3,3521.3,3522.3,3523.3,3524.3,3525.3,3526.3,3527.3,3528.3,3529.3,3530.3,3531.3,3532.3,3533.3,3534.3,3535.3,3536.3,3537.3,3538.3,3539.3,3540.3,3541.3,3542.3,3543.3,3544.3,3545.3,3546.3,3547.3,3548.3,3549.3,3550.3,3551.3,3552.3,3553.3,3554.3,3555.3,3556.3,3557.3,3558.3,3559.3,3560.3,3561.3,3562.3,3563.3,3564.3,3565.3,3566.3,3567.3,3568.3,3569.3,3570.3,3571.3,3572.3,3573.3,3574.3,3575.3,3576.3,3577.3,3578.3,3579.3,3580.3,3581.3,3582.3,3583.3,3584.3,3585.3,3586.3,3587.3,3588.3,3589.3,3590.3,3591.3,3592.3,3593.3,3594.3,3595.3,3596.3,3597.3,3598.3,3599.3,3600.3,3601.3,3602.3,3603.3,3604.3,3605.3,3606.3,3607.3,3608.3,3609.3,3610.3,3611.3,3612.3,3613.3,3614.3,3615.3,3616.3,3617.3,3618.3,3619.3,3620.3,3621.3,3622.3,3623.3,3624.3,3625.3,3626.3,3627.3,3628.3,3629.3,3630.3,3631.3,3632.3,3633.3,3634.3,3635.3,3636.3,3637.3,3638.3,3639.3,3640.3,3641.3,3642.3,3643.3,3644.3,3645.3,3646.3,3647.3,3648.3,3649.3,3650.3,3651.3,3652.3,3653.3,3654.3,3655.3,3656.3,3657.3,3658.3,3659.3,3660.3,3661.3,3662.3,3663.3,3664.3,3665.3,3666.3,3667.3,3668.3,3669.3,3670.3,3671.3,3672.3,3673.3,3674.3,3675.3,3676.3,3677.3,3678.3,3679.3,3680.3,3681.3,3682.3,3683.3,3684.3,3685.3,3686.3,3687.3,3688.3,3689.3,3690.3,3691.3,3692.3,3693.3,3694.3,3695.3,3696.3,3697.3,3698.3,3699.3,3700.3,3701.3,3702.3,3703.3,3704.3,3705.3,3706.3,3707.3,3708.3,3709.3,3710.3,3711.3,3712.3,3713.3,3714.3,3715.3,3716.3,3717.3,3718.3,3719.3,3720.3,3721.3,3722.3,3723.3,3724.3,3725.3,3726.3,3727.3,3728.3,3729.3,3730.3,3731.3,3732.3,3733.3,3734.3,3735.3,3736.3,3737.3,3738.3,3739.3,3740.3,3741.3,3742.3,3743.3,3744.3,3745.3,3746.3,3747.3,3748.3,3749.3,3750.3,3751.3,3752.3,3753.3,3754.3,3755.3,3756.3,3757.3,3758.3,3759.3,3760.3,3761.3,3762.3,3763.3,3764.3,3765.3,3766.3,3767.3,3768.3,3769.3,3770.3,3771.3,3772.3,3773.3,3774.3,3775.3,3776.3,3777.3,3778.3,3779.3,3780.3,3781.3,3782.3,3783.3,3784.3,3785.3,3786.3,3787.3,3788.3,3789.3,3790.3,3791.3,3792.3,3793.3,3794.3,3795.3,3796.3,3797.3,3798.3,3799.3,3800.3,3801.3,3802.3,3803.3,3804.3,3805.3,3806.3,3807.3,3808.3,3809.3,3810.3,3811.3,3812.3,3813.3,3814.3,3815.3,3816.3,3817.3,3818.3,3819.3,3820.3,3821.3,3822.3,3823.3,3824.3,3825.3,3826.3,3827.3,3828.3,3829.3,3830.3,3831.3,3832.3,3833.3,3834.3,3835.3,3836.3,3837.3,3838.3,3839.3,3840.3,3841.3,3842.3,3843.3,3844.3,3845.3,3846.3,3847.3,3848.3,3849.3,3850.3,3851.3,3852.3,3853.3,3854.3,3855.3,3856.3,3857.3,3858.3,3859.3,3860.3,3861.3,3862.3,3863.3,3864.3,3865.3,3866.3,3867.3,3868.3,3869.3,3870.3,3871.3,3872.3,3873.3,3874.3,3875.3,3876.3,3877.3,3878.3,3879.3,3880.3,3881.3,3882.3,3883.3,3884.3,3885.3,3886.3,3887.3,3888.3,3889.3,3890.3,3891.3,3892.3,3893.3,3894.3,3895.3,3896.3,3897.3,3898.3,3899.3,3900.3,3901.3,3902.3,3903.3,3904.3,3905.3,3906.3,3907.3,3908.3,3909.3,3910.3,3911.3,3912.3,3913.3,3914.3,3915.3,3916.3,3917.3,3918.3,3919.3,3920.3,3921.3,3922.3,3923.3,3924.3,3925.3,3926.3,3927.3,3928.3,3929.3,3930.3,3931.3,3932.3,3933.3,3934.3,3935.3,3936.3,3937.3,3938.3,3939.3,3940.3,3941.3,3942.3,3943.3,3944.3,3945.3,3946.3,3947.3,3948.3,3949.3,3950.3,3951.3,3952.3,3953.3,3954.3,3955.3,3956.3,3957.3,3958.3,3959.3,3960.3,3961.3,3962.3,3963.3,3964.3,3965.3,3966.3,3967.3,3968.3,3969.3,3970.3,3971.3,3972.3,3973.3,3974.3,3975.3,3976.3,3977.3,3978.3,3979.3,3980.3,3981.3,3982.3,3983.3,3984.3,3985.3,3986.3,3987.3,3988.3,3989.3,3990.3,3991.3,3992.3,3993.3,3994.3,3995.3,3996.3,3997.3,3998.3,3999.3,4000.3,4001.3,4002.3,4003.3,4004.3,4005.3,4006.3,4007.3,4008.3,4009.3,4010.3,4011.3,4012.3,4013.3,4014.3,4015.3,4016.3,4017.3,4018.3,4019.3,4020.3,4021.3,4022.3,4023.3,4024.3,4025.3,4026.3,4027.3,4028.3,4029.3,4030.3,4031.3,4032.3,4033.3,4034.3,4035.3,4036.3,4037.3,4038.3,4039.3,4040.3,4041.3,4042.3,4043.3,4044.3,4045.3,4046.3,4047.3,4048.3,4049.3,4050.3,4051.3,4052.3,4053.3,4054.3,4055.3,4056.3,4057.3,4058.3,4059.3,4060.3,4061.3,4062.3,4063.3,4064.3,4065.3,4066.3,4067.3,4068.3,4069.3,4070.3,4071.3,4072.3,4073.3,4074.3,4075.3,4076.3,4077.3,4078.3,4079.3,4080.3,4081.3,4082.3,4083.3,4084.3,4085.3,4086.3,4087.3,4088.3,4089.3,4090.3,4091.3,4092.3,4093.3,4094.3,4095.3,4096.3,4097.3,4098.3,4099.3,4100.3,4101.3,4102.3,4103.3,4104.3,4105.3,4106.3,4107.3,4108.3,4109.3,4110.3,4111.3,4112.3,4113.3,4114.3,4115.3,4116.3,4117.3,4118.3,4119.3,4120.3,4121.3,4122.3,4123.3,4124.3,4125.3,4126.3,4127.3,4128.3,4129.3,4130.3,4131.3,4132.3,4133.3,4134.3,4135.3,4136.3,4137.3,4138.3,4139.3,4140.3,4141.3,4142.3,4143.3,4144.3,4145.3,4146.3,4147.3,4148.3,4149.3,4150.3,4151.3,4152.3,4153.3,4154.3,4155.3,4156.3,4157.3,4158.3,4159.3,4160.3,4161.3,4162.3,4163.3,4164.3,4165.3,4166.3,4167.3,4168.3,4169.3,4170.3,4171.3,4172.3,4173.3,4174.3,4175.3,4176.3,4177.3,4178.3,4179.3,4180.3,4181.3,4182.3,4183.3,4184.3,4185.3,4186.3,4187.3,4188.3,4189.3,4190.3,4191.3,4192.3,4193.3,4194.3,4195.3,4196.3,4197.3,4198.3,4199.3,4200.3,4201.3,4202.3,4203.3,4204.3,4205.3,4206.3,4207.3,4208.3,4209.3,4210.3,4211.3,4212.3,4213.3,4214.3,4215.3,4216.3,4217.3,4218.3,4219.3,4220.3,4221.3,4222.3,4223.3,4224.3,4225.3,4226.3,4227.3,4228.3,4229.3,4230.3,4231.3,4232.3,4233.3,4234.3,4235.3,4236.3,4237.3,4238.3,4239.3,4240.3,4241.3,4242.3,4243.3,4244.3,4245.3,4246.3,4247.3,4248.3,4249.3,4250.3,4251.3,4252.3,4253.3,4254.3,4255.3,4256.3,4257.3,4258.3,4259.3,4260.3,4261.3,4262.3,4263.3,4264.3,4265.3,4266.3,4267.3,4268.3,4269.3,4270.3,4271.3,4272.3,4273.3,4274.3,4275.3,4276.3,4277.3,4278.3,4279.3,4280.3,4281.3,4282.3,4283.3,4284.3,4285.3,4286.3,4287.3,4288.3,4289.3,4290.3,4291.3,4292.3,4293.3,4294.3,4295.3,4296.3,4297.3,4298.3,4299.3,4300.3,4301.3,4302.3,4303.3,4304.3,4305.3,4306.3,4307.3,4308.3,4309.3,4310.3,4311.3,4312.3,4313.3,4314.3,4315.3,4316.3,4317.3,4318.3,4319.3,4320.3,4321.3,4322.3,4323.3,4324.3,4325.3,4326.3,4327.3,4328.3,4329.3,4330.3,4331.3,4332.3,4333.3,4334.3,4335.3,4336.3,4337.3,4338.3,4339.3,4340.3,4341.3,4342.3,4343.3,4344.3,4345.3,4346.3,4347.3,4348.3,4349.3,4350.3,4351.3,4352.3,4353.3,4354.3,4355.3,4356.3,4357.3,4358.3,4359.3,4360.3,4361.3,4362.3,4363.3,4364.3,4365.3,4366.3,4367.3,4368.3,4369.3,4370.3,4371.3,4372.3,4373.3,4374.3,4375.3,4376.3,4377.3,4378.3,4379.3,4380.3,4381.3,4382.3,4383.3,4384.3,4385.3,4386.3,4387.3,4388.3,4389.3,4390.3,4391.3,4392.3,4393.3,4394.3,4395.3,4396.3,4397.3,4398.3,4399.3,4400.3,4401.3,4402.3,4403.3,4404.3,4405.3,4406.3,4407.3,4408.3,4409.3,4410.3,4411.3,4412.3,4413.3,4414.3,4415.3,4416.3,4417.3,4418.3,4419.3,4420.3,4421.3,4422.3,4423.3,4424.3,4425.3,4426.3,4427.3,4428.3,4429.3,4430.3,4431.3,4432.3,4433.3,4434.3,4435.3,4436.3,4437.3,4438.3,4439.3,4440.3,4441.3,4442.3,4443.3,4444.3,4445.3,4446.3,4447.3,4448.3,4449.3,4450.3,4451.3,4452.3,4453.3,4454.3,4455.3,4456.3,4457.3,4458.3,4459.3,4460.3,4461.3,4462.3,4463.3,4464.3,4465.3,4466.3,4467.3,4468.3,4469.3,4470.3,4471.3,4472.3,4473.3,4474.3,4475.3,4476.3,4477.3,4478.3,4479.3,4480.3,4481.3,4482.3,4483.3,4484.3,4485.3,4486.3,4487.3,4488.3,4489.3,4490.3,4491.3,4492.3,4493.3,4494.3,4495.3,4496.3,4497.3,4498.3,4499.3,4500.3,);
# GlycoDB as released and reduced glycan masses: my @unsortedRepIons = (735.302968,751.297882,897.355791,913.350705,954.377255,993.317036,1059.408614,1075.403528,1100.435164,1116.430078,1155.369859,1157.456628,1196.396409,1221.461437,1237.456351,1246.493073,1262.487987,1278.482901,1303.514537,1317.422682,1319.509451,1358.449232,1383.51426,1397.389013,1399.509174,1407.525495,1408.545896,1423.520409,1424.54081,1440.535724,1449.572446,1465.56736,1479.475505,1481.562274,1520.502055,1522.588824,1553.583404,1559.441836,1561.561997,1569.578318,1570.598719,1585.573232,1586.593633,1595.630355,1600.468386,1602.588547,1610.604868,1611.625269,1626.599782,1627.620183,1641.528328,1643.615097,1668.646733,1682.554878,1684.641647,1699.641313,1715.636227,1721.494659,1723.61482,1725.668197,1731.631141,1732.651542,1747.626055,1748.646456,1756.662777,1757.683178,1762.521209,1764.64137,1772.657691,1773.678092,1788.652605,1789.673006,1803.547759,1803.581151,1805.66792,1814.704642,1830.699556,1844.607701,1846.69447,1861.694136,1871.726106,1877.68905,1885.667643,1887.72102,1893.683964,1894.704365,1902.720686,1909.678878,1910.699279,1918.7156,1919.736001,1924.574032,1928.74757,1934.710514,1935.730915,1950.705428,1951.725829,1960.762551,1965.600582,1967.720743,1975.737064,1976.757465,1991.731978,1992.752379,2006.660524,2008.747293,2017.784015,2023.746959,2033.778929,2039.741873,2047.720466,2048.778595,2049.773843,2055.736787,2063.753108,2064.773509,2071.731701,2074.805479,2079.748022,2080.768423,2081.788824,2090.800393,2095.742936,2096.763337,2097.783738,2106.82046,2112.758251,2113.778652,2121.794973,2122.815374,2127.653405,2129.773566,2137.789887,2138.810288,2153.784801,2154.805202,2163.841924,2170.800116,2178.816437,2179.836838,2185.799782,2194.811351,2195.831752,2201.794696,2209.773289,2209.811017,2210.831418,2211.826666,2217.78961,2220.863388,2225.805931,2226.826332,2236.858302,2241.800845,2242.821246,2252.853216,2257.795759,2258.81616,2259.836561,2267.852882,2268.873283,2274.811074,2275.831475,2283.847796,2284.868197,2293.879766,2299.84271,2300.863111,2309.899833,2315.837624,2316.858025,2324.874346,2325.894747,2332.852939,2340.86926,2341.889661,2355.868926,2356.864174,2357.884575,2366.921297,2371.826112,2371.86384,2372.884241,2373.879489,2381.89581,2382.916211,2387.858754,2388.879155,2397.890724,2398.911125,2403.853668,2404.874069,2413.910791,2414.906039,2419.848582,2420.868983,2428.885304,2429.905705,2430.926106,2436.863897,2439.937675,2444.880218,2445.900619,2446.92102,2455.932589,2455.957742,2460.875132,2461.895533,2462.915934,2470.932255,2471.952656,2477.890447,2478.910848,2486.927169,2487.94757,2494.905762,2501.926835,2502.922083,2503.942484,2512.979206,2517.921749,2518.916997,2519.937398,2527.953719,2528.97412,2533.916663,2535.932312,2543.948633,2544.969034,2549.911577,2550.931978,2559.943547,2559.9687,2560.963948,2565.906491,2566.926892,2574.943213,2575.963614,2576.958862,2581.901405,2582.921806,2585.995584,2590.938127,2591.958528,2592.978929,2601.990498,2606.933041,2607.953442,2608.973843,2616.990164,2617.985412,2618.010565,2622.927955,2623.948356,2624.968757,2631.964677,2632.985078,2634.005479,2639.94327,2640.963671,2647.959591,2648.979992,2650.000393,2659.011962,2659.037115,2663.954505,2663.979658,2664.974906,2665.995307,2674.011628,2675.032029,2679.974572,2680.96982,2681.990221,2690.006542,2691.026943,2695.969486,2697.985135,2706.001456,2707.021857,2711.9644,2721.001122,2721.99637,2722.021523,2723.016771,2727.959314,2732.053493,2736.996036,2738.016437,2739.011685,2747.028006,2748.048407,2752.99095,2754.011351,2763.02292,2763.048073,2764.043321,2768.985864,2770.006265,2778.022586,2779.042987,2780.038235,2780.063388,2784.980778,2786.001179,2794.0175,2795.037901,2796.058302,2801.996093,2805.069871,2810.012414,2811.032815,2812.053216,2820.069537,2821.064785,2821.089938,2826.007328,2827.027729,2828.04813,2835.04405,2836.064451,2837.084852,2843.022643,2844.043044,2851.038964,2852.059365,2853.079766,2860.037958,2867.033878,2867.059031,2868.054279,2869.07468,2878.111402,2882.033544,2883.053945,2884.049193,2884.074346,2885.069594,2893.085915,2894.106316,2898.028458,2899.048859,2900.06926,2901.064508,2909.080829,2909.105982,2910.10123,2914.023372,2915.043773,2916.064174,2924.080495,2925.075743,2925.100896,2926.096144,2930.018286,2931.038687,2932.059088,2940.075409,2941.09581,2942.091058,2942.116211,2947.033601,2948.054002,2951.12778,2956.070323,2957.090724,2958.111125,2966.127446,2967.122694,2972.065237,2973.085638,2974.106039,2981.101959,2982.12236,2983.117608,2983.142761,2988.060151,2989.080552,2990.100953,2997.096873,2998.117274,2999.137675,3005.075466,3006.095867,3013.091787,3013.11694,3014.112188,3015.132589,3022.090781,3024.144158,3024.169311,3028.091453,3029.086701,3029.111854,3030.107102,3031.127503,3039.143824,3040.164225,3044.086367,3045.106768,3046.102016,3047.122417,3055.138738,3056.159139,3060.081281,3061.101682,3063.117331,3070.138404,3071.133652,3071.158805,3072.154053,3076.076195,3077.096596,3085.112917,3086.133318,3087.128566,3087.153719,3088.148967,3092.071109,3093.09151,3097.185689,3101.107831,3102.128232,3103.148633,3104.143881,3104.169034,3109.086424,3112.160202,3112.185355,3113.180603,3117.102745,3118.123146,3119.143547,3120.163948,3127.159868,3128.155116,3128.180269,3129.175517,3133.097659,3134.11806,3135.138461,3136.158862,3143.154782,3144.175183,3145.170431,3145.195584,3150.112974,3151.133375,3152.153776,3159.149696,3160.170097,3161.190498,3167.128289,3168.14869,3170.202067,3174.149362,3175.14461,3175.169763,3176.165011,3177.185412,3185.201733,3186.196981,3186.222134,3190.144276,3191.139524,3191.164677,3192.159925,3193.180326,3200.176246,3201.196647,3202.217048,3206.13919,3207.159591,3208.154839,3209.17524,3216.17116,3216.196313,3217.191561,3218.211962,3222.134104,3223.154505,3225.170154,3231.170826,3232.166074,3232.191227,3233.186475,3233.211628,3234.206876,3238.129018,3239.149419,3243.243598,3247.16574,3248.186141,3249.181389,3249.206542,3250.20179,3254.123932,3255.144333,3258.218111,3259.238512,3263.160654,3264.181055,3265.201456,3266.196704,3273.217777,3274.213025,3274.238178,3275.233426,3279.155568,3280.175969,3281.19637,3288.19229,3289.212691,3290.207939,3290.233092,3291.22834,3295.150482,3296.170883,3297.191284,3304.187204,3305.207605,3306.228006,3307.223254,3307.248407,3312.165797,3313.186198,3316.259976,3320.182118,3320.207271,3321.202519,3322.22292,3323.243321,3329.181112,3331.259642,3332.25489,3336.177032,3336.202185,3337.197433,3338.217834,3339.238235,3346.234155,3347.254556,3348.249804,3348.274957,3352.197099,3353.192347,3354.212748,3355.233149,3362.229069,3362.254222,3363.24947,3364.269871,3368.192013,3370.207662,3371.228063,3377.228735,3378.223983,3378.249136,3379.244384,3380.264785,3384.186927,3387.222977,3389.276354,3389.301507,3393.223649,3394.218897,3394.24405,3395.239298,3395.264451,3396.259699,3400.181841,3404.27602,3405.296421,3409.218563,3410.238964,3411.234212,3411.259365,3412.254613,3416.176755,3419.275686,3420.270934,3421.291335,3425.213477,3426.233878,3427.254279,3428.249527,3434.250199,3435.2706,3436.265848,3436.291001,3437.286249,3441.208391,3442.228792,3443.249193,3450.245113,3451.265514,3452.260762,3452.285915,3453.281163,3457.203305,3458.223706,3459.244107,3462.317885,3466.240027,3466.26518,3467.260428,3468.280829,3469.276077,3469.30123,3474.21862,3475.239021,3477.292398,3477.317551,3478.312799,3482.234941,3482.260094,3483.255342,3484.275743,3485.296144,3492.292064,3493.287312,3493.312465,3494.307713,3498.229855,3498.255008,3499.250256,3500.270657,3501.291058,3508.286978,3509.307379,3510.302627,3510.32778,3514.249922,3515.24517,3516.265571,3517.285972,3523.286644,3524.281892,3524.307045,3525.302293,3526.322694,3530.244836,3532.260485,3533.280886,3535.334263,3538.261157,3539.281558,3540.276806,3540.301959,3541.297207,3542.317608,3546.23975,3550.333929,3551.329177,3551.35433,3554.256071,3555.276472,3556.27172,3556.296873,3557.292121,3558.312522,3562.234664,3565.308442,3565.333595,3566.328843,3567.349244,3570.250985,3571.271386,3572.291787,3573.287035,3574.307436,3580.308108,3581.303356,3581.328509,3582.323757,3583.344158,3586.245899,3587.2663,3588.286701,3590.30235,3596.303022,3597.29827,3597.323423,3598.318671,3598.343824,3599.339072,3602.240813,3603.261214,3604.281615,3608.375794,3612.297936,3613.318337,3614.313585,3614.338738,3615.333986,3619.256128,3620.276529,3623.350307,3624.370708,3628.29285,3629.313251,3630.333652,3631.3289,3636.271443,3638.349973,3639.345221,3639.370374,3640.365622,3644.287764,3645.308165,3646.328566,3653.324486,3654.344887,3655.340135,3655.365288,3656.360536,3660.282678,3661.303079,3662.32348,3669.3194,3669.344553,3670.339801,3671.360202,3672.35545,3672.380603,3677.297993,3678.318394,3681.392172,3684.319066,3685.314314,3685.339467,3686.334715,3686.359868,3687.355116,3688.375517,3694.313308,3696.391838,3697.387086,3700.31398,3701.309228,3701.334381,3702.329629,3702.354782,3703.35003,3704.370431,3711.366351,3712.386752,3713.382,3713.407153,3716.308894,3717.329295,3718.324543,3718.349696,3719.344944,3720.365345,3726.366017,3727.361265,3727.386418,3728.381666,3729.402067,3732.303808,3733.324209,3734.34461,3735.339858,3736.360259,3741.34053,3742.360931,3743.356179,3743.381332,3744.37658,3745.396981,3748.298722,3749.319123,3750.339524,3752.355173,3754.433703,3757.335444,3758.355845,3759.351093,3759.376246,3760.371494,3760.396647,3761.391895,3764.293636,3765.314037,3766.334438,3769.408216,3770.428617,3773.330358,3774.350759,3775.37116,3776.366408,3776.391561,3777.386809,3781.308951,3782.329352,3784.407882,3785.40313,3786.423531,3789.325272,3790.345673,3791.366074,3792.386475,3793.381723,3799.382395,3800.402796,3801.398044,3801.423197,3802.418445,3805.320186,3806.340587,3807.360988,3808.381389,3815.377309,3815.402462,3816.39771,3817.392958,3817.418111,3818.413359,3822.335501,3823.355902,3824.376303,3827.450081,3830.376975,3831.372223,3831.397376,3832.392624,3833.413025,3834.408273,3834.433426,3839.350816,3840.371217,3842.424594,3842.449747,3843.444995,3846.371889,3847.367137,3847.39229,3848.387538,3849.407939,3850.42834,3857.42426,3858.419508,3858.444661,3859.439909,3862.366803,3863.362051,3863.387204,3864.382452,3865.402853,3866.423254,3872.423926,3873.419174,3874.439575,3875.434823,3875.459976,3878.361717,3879.382118,3880.377366,3881.397767,3882.418168,3887.398439,3888.41884,3889.414088,3889.439241,3890.434489,3891.45489,3894.356631,3895.377032,3897.392681,3898.413082,3903.393353,3904.413754,3905.409002,3905.434155,3906.429403,3907.449804,3910.351545,3911.371946,3915.466125,3916.486526,3919.388267,3920.408668,3921.403916,3921.429069,3922.424317,3923.444718,3926.346459,3927.36686,3930.440638,3930.465791,3931.461039,3932.48144,3935.383181,3936.403582,3937.423983,3938.419231,3939.439632,3943.361774,3945.440304,3946.435552,3946.460705,3947.455953,3948.476354,3951.378095,3952.398496,3953.418897,3955.434546,3961.435218,3962.430466,3962.455619,3963.450867,3963.47602,3964.471268,3967.373009,3968.39341,3969.413811,3973.50799,3976.434884,3977.430132,3977.455285,3978.450533,3979.445781,3979.470934,3980.466182,3984.388324,3985.408725,3988.482503,3989.502904,3992.429798,3993.425046,3993.450199,3994.445447,3995.465848,3996.461096,4001.403639,4003.482169,4004.477417,4004.50257,4005.497818,4008.424712,4009.41996,4009.445113,4010.440361,4011.460762,4018.456682,4018.481835,4019.477083,4020.472331,4020.497484);#for testing
#TMTglycoproteomics: my @unsortedRepIons = (126.12772,127.124761,127.131081,128.128116,128.134436,129.131471,129.137790,130.134825,130.141145,131.138180,131.144500,132.141535,132.147855,133.144890,133.151210,134.148245,134.154565,135.151600,126.054955,127.038970,128.054955,138.054955,144.065519,145.049535,163.0601,168.065519,186.076084,204.086649,243.02643,274.092128,290.08702,292.102693,308.09757,323.224,366.139472,528.192296,657.235438,369.1420,351.1314,531.1943,184.0732);

my $precision = 0.05; # +/- precision in amu, default value: 0.05
my $IgnoreLowMoverZRange = 0; # no deconv or deisotope m/z range below given amu

#----end of PARAMETERS

my $MGF_OUTFILE_NAME;
my $REP_OUTFILE_NAME;
my $MGF_INFILE_NAME;
my $MASS;
my $TITLE;
my $PEPMASS; 
my $PRECURSOR_INTENSITY;
my $CHARGE;
my $RTINSECONDS=0;
my $SCANS=0;
my $NUMBER_MS2SCANS_TOTAL;
my $NUMBER_MS2SCANS_FILTERED;

my @arr1 = ();
my @arr2 = ();
my @v = ();
my $precursor;
my $x;
my $y;
my $i;	

my @RepIons = sort {$a <=> $b} @unsortedRepIons; #sort RepIons list by MoverZ

print "---SugarQBits RepX---\n";
print "parameters:\n";
print "mass precision = +/-$precision amu\n";
print "lower mass exemption < $IgnoreLowMoverZRange amu\n";
print "Reporter Ions:\n";

foreach $x (@RepIons) {
	print $x."\n";
}
print "---   ---\n";

print "INPUT (.mgf) FILE DIRECTORY (full path):>\n";

my $dirname = <>;

chop($dirname);

opendir(DIR, $dirname) or die "Could not open $dirname\n";

my @files = readdir(DIR);

shift @files; #get rid of "."

shift @files; #get rid of ".."

closedir(DIR);

foreach $MGF_INFILE_NAME (@files) {

	$MGF_INFILE_NAME = join ("\\\\", $dirname, $MGF_INFILE_NAME);

	if ($MGF_INFILE_NAME =~ /.MGF/ || $MGF_INFILE_NAME =~ /.mgf/ ){
		
		print "SugarQbits RepX $MGF_INFILE_NAME...";

		open(INFILE,"<$MGF_INFILE_NAME") || die "$MGF_INFILE_NAME not found!\n";
		
		$NUMBER_MS2SCANS_TOTAL = 0; #reset counter
		
		$NUMBER_MS2SCANS_FILTERED = 0;#reset counter

		$MGF_OUTFILE_NAME = ">>".substr ($MGF_INFILE_NAME,0,-4)."_RepX.mgf";

		open (OUTFILE1, $MGF_OUTFILE_NAME);

		$REP_OUTFILE_NAME = ">>".substr ($MGF_INFILE_NAME,0,-4)."_RepIntensities.csv";

		open (OUTFILE2, $REP_OUTFILE_NAME);

		#---write header for csv file

		print OUTFILE2 "MS2 Spectrum Title,Rtime";
				
		for ($x = 0; $x < @RepIons; $x++) { 
		
			print OUTFILE2 ",".$RepIons[$x];		
		
		}
				
		print OUTFILE2 "\n";

		while (<INFILE>){

		chomp;

		@v = split (/=|\s/, $_);
	
		if ($v[0] eq "BEGIN"){
		
			#reset variables and empty arrays of data from previous MS2-spectrum
			
			@arr1 = ();
		
			@arr2 = ();
		
			$NUMBER_MS2SCANS_TOTAL++;
		
			#reset RepIons array arr2
			
			for ($x = 0; $x < @RepIons; $x++) { 
		
				$arr2[$x][0] = $RepIons[$x];
		
				$arr2[$x][1] = 0;	
			
			}
									
		}elsif($v[0] eq "TITLE"){#MGF-MS2-spectrum title
				
			$TITLE = $v[1];	#will truncate msconvert generated "TPP-compatible" spectrum titles, removing all space separated content...
									
		}elsif ($v[0] eq "PEPMASS"){#MGF precursor ion m/z and its intensity
			
			$PEPMASS = $v[1];
			
			if (scalar @v > 2) {
			
				$PRECURSOR_INTENSITY = $v[2];
		
			}else{ #PEAKS generated mgf files do not contain precursor intensity values
		
				$PRECURSOR_INTENSITY = 0;
			
			}
				
		}elsif ($v[0] eq "CHARGE"){#MGF precursor charge state
				
			$CHARGE = substr $v[1], 0, 1; #remove + sign from charge.
				
		}elsif ($v[0] eq "RTINSECONDS"){#MGFclassics RetentionTimeINSECONDS
			
			$RTINSECONDS = $v[1];
			
		}elsif ($v[0] eq "SCANS"){#MGF MS2-spectrum scan number
			
			$SCANS = $v[1]
				
		}elsif ($v[0] eq "END"){
		
			$NUMBER_MS2SCANS_FILTERED++;
		
			print OUTFILE1 "BEGIN IONS\n";
					
			print OUTFILE1 "TITLE=SQbRepX_".$TITLE."\nSCANS=$SCANS\nPEPMASS=$PEPMASS $PRECURSOR_INTENSITY\nCHARGE=$CHARGE+\n";
				
			for ($x = 0 ; $x < @arr1; $x++){
						
				if ($arr1[$x][1] > 0){ #only print value pairs with intensity > 0
							
					print OUTFILE1 "$arr1[$x][0] $arr1[$x][1]\n";

				}
				
			}
				
			print OUTFILE1 "END IONS\n";
			
				
			print OUTFILE2 "TITLE=SQbRepX_".$TITLE.",$RTINSECONDS";
				
			for ($x = 0; $x < @RepIons; $x++) { 
		
				print OUTFILE2 ",".$arr2[$x][1];		
		
			}
				
			print OUTFILE2 "\n";

		}elsif ($v[0] !~ /[a-df-zA-DF-Z]/ && $v[1] !~ /[a-df-zA-DF-Z]/) { #Lines that do not contain letters (but "E" for exponential numbers) are deemed MS2 data pairs
		
			if ($v[0] < $arr2[(@RepIons - 1)][0] + $precision){					
					
				for ($x = 0; $x < @RepIons; $x++) {
					
					if ($v[0] < $arr2[$x][0] + $precision && $v[0] > $arr2[$x][0] - $precision ){

						
						if ($arr2[$x][1] != 0) {

							$arr2[$x][1] = $arr2[$x][1] + $v[1];
														
							$v[1] = 0; #remove RepIons from MS2 spectrum by setting Intensity value to 0
					
						
						}else{
							
							$arr2[$x][1] = $v[1];
							
							$v[1] = 0; #still remove RepIons from MS2 spectrum by setting Intensity value to 0?
						
						}
					
					}

				}
					
			}
					
			push @arr1, [$v[0], $v[1]];
	
		}else{
		
			print "dont know what to do with: $v[0]-$v[1]\n";
		
		}	
		
	}
	
	close OUTFILE2;

	close OUTFILE1;

	close INFILE;
	
	print "done!\n($NUMBER_MS2SCANS_FILTERED RepXFiltered/$NUMBER_MS2SCANS_TOTAL total)\n";

}

}