using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; //using System.Numerics; using System.Text; using System.Threading; public class Solver { void Solve() { int n = ReadInt(); var a = ReadIntArray(); int nl = n / 2; int nr = n - nl; var dl = Init<SDictionary<int, int>>(nl + 1); dl[0][0] = 1; for (int len = 1; len <= nl; len++) { for (int i = 0; i < 1 << len - 1; i++) { int s = a[0]; int x = 0; for (int j = 0; j + 1 < len; j++) if ((i >> j & 1) == 1) s += a[j + 1]; else { x ^= s; s = a[j + 1]; } x ^= s; dl[len][x]++; } } var dr = Init<SDictionary<int, int>>(nr + 1); dr[0][0] = 1; for (int len = 1; len <= nr; len++) { for (int i = 0; i < 1 << len - 1; i++) { int s = a[n - 1]; int x = 0; for (int j = 0; j + 1 < len; j++) if ((i >> j & 1) == 1) s += a[n - j - 2]; else { x ^= s; s = a[n - j - 2]; } x ^= s; dr[len][x]++; } } long ans = 0; foreach (var kvp in dl[nl]) ans += 1L * kvp.Value * dr[nr][kvp.Key]; for (int l = 0; l < nl; l++) for (int r = nl; r < n; r++) { int s = 0; for (int i = l; i <= r; i++) s += a[i]; foreach (var kvp in dl[l]) ans += 1L * kvp.Value * dr[n - r - 1][kvp.Key ^ s]; } Write(ans); } #region Main protected static TextReader reader; protected static TextWriter writer; static void Main() { #if DEBUG reader = new StreamReader("..\\..\\input.txt"); //reader = new StreamReader(Console.OpenStandardInput()); writer = Console.Out; //writer = new StreamWriter("..\\..\\output.txt"); #else reader = new StreamReader(Console.OpenStandardInput()); writer = new StreamWriter(Console.OpenStandardOutput()); //reader = new StreamReader("transform.in"); //writer = new StreamWriter("transform.out"); #endif try { //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128); //thread.Start(); //thread.Join(); new Solver().Solve(); } catch (Exception ex) { Console.WriteLine(ex); #if DEBUG #else throw; #endif } reader.Close(); writer.Close(); } #endregion #region Read / Write private static Queue<string> currentLineTokens = new Queue<string>(); private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); } public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); } public static int ReadInt() { return int.Parse(ReadToken()); } public static long ReadLong() { return long.Parse(ReadToken()); } public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); } public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); } public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); } public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); } public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; } public static int[][] ReadAndTransposeIntMatrix(int numberOfRows) { int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][]; for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret; } public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; } public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); } public static void Write(params object[] array) { WriteArray(array); } public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); } private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue> { public new TValue this[TKey key] { get { return ContainsKey(key) ? base[key] : default(TValue); } set { base[key] = value; } } } private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; } private static void Decrease(int[] a) { for (int i = 0; i < a.Length; i++) a[i]--; } #endregion }