diff --git a/geostat.cpp b/geostat.cpp
index ed17504..217b6f3 100644
--- a/geostat.cpp
+++ b/geostat.cpp
@@ -287,7 +287,8 @@ int main(int argc, char** argv) {
tot_dist += cache_distance(*i->second, *std::next(i)->second);
}
std::cout << "Total distance between caches: " << tot_dist << " km (equivalent to " << tot_dist / (2 * Pi * Earth_radius) << "x trips around Earth)
\n";
- std::cout << "Average distance between caches: " << tot_dist / sorted_fcaches.size() << " km
\n";
+ if (sorted_fcaches.size() > 1)
+ std::cout << "Average distance between caches: " << tot_dist / (sorted_fcaches.size() - 1) << " km
\n";
std::cout << "\n";
}