Bell inequality with an arbitrary number of settings and its applications