Assuming the book has a total of n pages, Lili read 78 pages in the first 3 days, then there are still n - 3 × 78 = n - 262 pages not read. In the next four days, she read an average of 40 pages a day. In these four days, Lili read a total of 40 × 4 = 160 pages. Therefore, Lili had read a total of n - 262 + 160 = 322 pages, just enough to finish the book. So this book had 322 pages.