code: public static int Median( int[] values ){
          int total = 0, n = values.length;
  
          // for all values
          for ( int i = 0; i < n; i++ )
          {
              // accumalate total
              total += values[i];
          }
  
          int halfTotal = total / 2;
          int median = 0, v = 0;
  
          // find median value
          for ( ; median < n; median++ )
          {
              v += values[median];
              if ( v >= halfTotal )
                  break;
          }
  
          return median;
      }
docs: Calculate Median value.
  @param values Values.
  @return Median.